Skip to content

Commit

Permalink
newer version of separating upcoming activities mendicant#19
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Jul 7, 2012
1 parent 8e4dd0c commit b7f87c7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions activities.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ header:
---

<ul class="posts">
{% assign past_header_shown = false %}
{% for post in site.categories.activities %}
{% unless post.next %}
{% if site.time < post.date %}
<h2>upcoming</h2>
{% else %}
<h2>past</h2>
{% assign past_header_shown = true %}
{% endif %}
{% else %}
{% if site.time >= post.date and past_header_shown == false %}
<h2>past</h2>
{% assign past_header_shown = true %}
{% endif %}
{% endunless %}

{% include post.html %}
{% endfor %}
</ul>

1 comment on commit b7f87c7

@daniely
Copy link
Owner

@daniely daniely commented on b7f87c7 Jul 7, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post.next is weird. On the first iteration it will be falsey, then on subsequent iterations it'll be truthy. I don't understand why it's falsey on the first iteration. Anyway, it's used here with unless to make sure something happens only on the first iteration.

Here's the source for post.next

# File 'lib/jekyll/post.rb', line 237

def next
  pos = self.site.posts.index(self)

  if pos && pos < self.site.posts.length-1
    self.site.posts[pos+1]
  else
    nil
  end
end

Please sign in to comment.