mirror of
https://github.com/nicolabs/nicolabs.net.git
synced 2025-09-07 16:27:21 +02:00
77 lines
2.9 KiB
HTML
77 lines
2.9 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.
|
|
|
|
It also removes duplicates with different character case :
|
|
`normtags` is the list of normalized tags (lower case) ; each tag is normalized and tested
|
|
against this list before being added to the final list.
|
|
=======================
|
|
{% endcomment %}
|
|
{% assign tags = "" %}
|
|
{% assign normtags = "" %}
|
|
{% for tag in rawtags %}
|
|
{% assign norm_tag = tag|downcase %}
|
|
{% if tag != "" %}
|
|
{% if tags == "" %}
|
|
{% assign tags = tag | split:'|' %}
|
|
{% endif %}
|
|
{% unless normtags contains norm_tag %}
|
|
{% assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' %}
|
|
{% assign normtags = normtags | join:'|' | append:'|' | append:norm_tag | split:'|' %}
|
|
{% endunless %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% comment %}
|
|
=======================
|
|
The purpose of this snippet is to list all your posts posted with a certain tag.
|
|
|
|
norm_tag and normtags are the current tag and the current post's tags
|
|
in a normalized format (lower case) to be able to remove duplicates with different case
|
|
=======================
|
|
{% 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 %}
|
|
|
|
{% assign norm_tag = tag|downcase %}
|
|
{% assign normtags = post.tags | join:'|' | downcase | split:'|' %}
|
|
{% if normtags contains norm_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 %}
|