Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions posts.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
---
---
layout: page
title: posts | brainfucksec
---

<section>
{% if site.posts[0] %}
{% assign filtered_posts = site.posts | where_exp: "post", "post.hidden != true" | sort: "date" | reverse %}
{% if filtered_posts.size > 0 %}

{% capture currentyear %}{{ 'now' | date: "%Y" }}{% endcapture %}
{% capture firstpostyear %}{{ site.posts[0].date | date: '%Y' }}{% endcapture %}
{% if currentyear == firstpostyear %}
{% capture postyear %}{{ filtered_posts[0].date | date: '%Y' }}{% endcapture %}
{% if currentyear == postyear %}
<h3>This year's posts</h3>
{% else %}
<h3>{{ firstpostyear }}</h3>
<h3>{{ postyear }}</h3>
{% endif %}

{%for post in site.posts %}
{% unless post.next %}
<ul>
{% else %}
<ul>
{% for post in filtered_posts %}
{% capture year %}{{ post.date | date: '%Y' }}{% endcapture %}
{% capture nyear %}{{ post.next.date | date: '%Y' }}{% endcapture %}
{% if year != nyear %}
</ul>
<h3>{{ post.date | date: '%Y' }}</h3>
<ul>
{% endif %}
{% endunless %}

<li><time>{{ post.date | date:"%d %b" }} - </time>
<a href="{{ post.url | prepend: site.baseurl | replace: '//', '/' }}">
{{ post.title }}
</a>
<a href="{{ post.url | prepend: site.baseurl | replace: '//', '/' }}">{{ post.title }}</a>
</li>

{% if forloop.last == false %}
{% assign nindex = forloop.index0 | plus: 1 %}
{% assign nyear = filtered_posts[nindex].date | date: '%Y' %}
{% if year != nyear %}
</ul>
<h3>{{ nyear }}</h3>
<ul>
{% endif %}
{% endif %}
{% endfor %}
</ul>

{% endif %}

{% else %}
<h3>No posts to display</h3>
{% endif %}
</section>