mirror of
https://github.com/nicolabs/nicolabs.net.git
synced 2025-09-21 00:32:01 +02:00
64 lines
2.2 KiB
HTML
64 lines
2.2 KiB
HTML
---
|
|
layout: page
|
|
title: Articles by tag
|
|
---
|
|
|
|
{% comment %}
|
|
See https://codinfox.github.io/dev/2015/03/06/use-tags-and-categories-in-your-jekyll-based-github-pages/
|
|
{% endcomment %}
|
|
|
|
{% include allposts.liquid %}
|
|
|
|
<h2 class="chapter-links">
|
|
<a href="{{ '/articles' | prepend: site.baseurl }}">all articles</a>
|
|
</h2>
|
|
|
|
{% 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 allposts %}
|
|
{% assign ttags = post.tags | join:'|' | append:'|' %}
|
|
{% assign rawtags = rawtags | append:ttags %}
|
|
{% endfor %}
|
|
{% assign rawtags = rawtags | split:'|' | sort_natural %}
|
|
|
|
{% comment %}
|
|
=======================
|
|
The following part removes duplicated 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 allposts %}
|
|
{% 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 %}
|