Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Granular date and time control when publishing articles #52

Closed
procload opened this issue Jun 21, 2012 · 5 comments
Closed

Granular date and time control when publishing articles #52

procload opened this issue Jun 21, 2012 · 5 comments

Comments

@procload
Copy link

Specifically when publishing multiple articles on one day. I currently I have a loop that looks like the following:

<% data.blog.articles[0...5].each do |article| %>
  <article>
    ...article content...
  </article>
<% end %>

Which lists the 5 most recent articles on my index page, but when I publish more than one article per day it sorts them in chronological order, where I would like them to be reverse chron, like a blog typically is. Is there an easy way to reorder this so it works in a typical blog format, with the newest article of that day appearing first?

@bhollis
Copy link
Contributor

bhollis commented Jun 21, 2012

If you upgrade to Middleman 3.0, this should work better. In 3.0, you can put a full DateTime in the frontmatter "date" field, and the extension sorts based on that.

@procload
Copy link
Author

Any way you could give me an example of how to achieve this and parse it in an article view? Many thanks in advance.

Ryan Merrill
ryan@helloample.com (mailto:ryan@helloample.com)
440.452.6174

On Thursday, June 21, 2012 at 12:23 PM, Ben Hollis wrote:

If you upgrade to Middleman 3.0, this should work better. In 3.0, you can put a full DateTime in the frontmatter "date" field, and the extension sorts based on that.


Reply to this email directly or view it on GitHub:
#52 (comment)

@bhollis
Copy link
Contributor

bhollis commented Jun 22, 2012

Nothing to do, really. You make a blog post, like this (in a file called 2012-06-21-my-awesome-post.html.markdown):

---
title: My awesome post
date: 2012-06-21 10:00
---

Hey guys my day was awesome!

Then your original snippet becomes:

<% blog.articles[0...5].each do |article| %>
  <article>
    Title: <%= article.title %>
    Date: <%= article.date %>
  </article>
<% end %>

And without doing anything, the articles will already be sorted by date.

@bhollis
Copy link
Contributor

bhollis commented Jul 4, 2012

@procload did that work for you?

@procload
Copy link
Author

procload commented Jul 5, 2012

Sure did. Sorry for not replying. Thanks a bunch for the help.

@procload procload closed this as completed Jul 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants