nicolabs.net/tags.html
nicobo fd78448da1 - post-share.html renamed to post-footer.hmtl
- `about.md` moved to root
- tags link to the new 'tags' page
2019-04-27 08:21:32 +02:00

58 lines
2.1 KiB
HTML

---
layout: page
title: Posts by tag
---
{% comment %}
See https://codinfox.github.io/dev/2015/03/06/use-tags-and-categories-in-your-jekyll-based-github-pages/
{% endcomment %}
{% comment %}
=======================
The following part extracts all the tags from your posts and sort tags, so that you do not need to manually collect your tags to a place.
=======================
{% endcomment %}
{% assign rawtags = "" %}
{% for post in site.posts %}
{% assign ttags = post.tags | join:'|' | append:'|' %}
{% assign rawtags = rawtags | append:ttags %}
{% endfor %}
{% assign rawtags = rawtags | split:'|' | sort %}
{% comment %}
=======================
The following part removes dulpicated tags and invalid tags like blank tag.
=======================
{% endcomment %}
{% assign tags = "" %}
{% for tag in rawtags %}
{% if tag != "" %}
{% if tags == "" %}
{% assign tags = tag | split:'|' %}
{% endif %}
{% unless tags contains tag %}
{% assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' %}
{% endunless %}
{% endif %}
{% endfor %}
{% comment %}
=======================
The purpose of this snippet is to list all your posts posted with a certain tag.
=======================
{% endcomment %}
{% for tag in tags %}
<h2 class="tag" id="{{ tag | slugify }}"><a href="#{{tag | slugify}}"><span class="tag-decoration">#</span>{{ tag }}</a></h2>
<ul>
{% for post in site.posts %}
{% if post.tags contains tag %}
<li>
<strong><a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></strong>
<span class="post-meta-separator"></span> <time class="post-meta datePublished" datetime="{{ post.date | date_to_xmlschema }}" itemprop="datePublished">{{ post.date | date: "%b %-d, %Y" }}</time>
{% if post.last_modified_at %}<span class="post-meta-separator"></span> <time class="post-meta dateModified" datetime="{{ post.last_modified_at | date_to_xmlschema }}" itemprop="dateModified">Updated on {{ post.last_modified_at | date: "%b %-d, %Y" }}</time>{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}