~ane/web

web/tags.html -rw-r--r-- 1.7 KiB
adb02267Antoine Kalmbach fix build a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
layout: page
title: Index
---

<h2> Tag index</h2>

<p>
  Here are all posts and pages indexed by their tags.
</p>

<!-- Get the tag name for every tag on the site and set them
     to the `site_tags` variable. -->
{% capture site_tags %}{% for tag in site.tags %}{{ tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}

{% assign tag_words = site_tags | split:',' | sort %}

{% assign coll = site.collections %}
{% for c in coll %}
  {% for p in c.docs %}
    {% assign tag_words = tag_words | concat: p.tags %}
  {% endfor %}
{% endfor %}

{% assign tag_words = tag_words | sort | uniq %}

<div style="display: flex; flex-direction: row;">
  <div style="flex-basis: 15%;"><b>Jump to:</b></div>
  <ul style="list-style: none; display: flex; flex-direction: row; justify-content: space-between; padding: 0; flex-grow: 1; margin: 0;">
    {% assign grouped = tag_words | group_by_exp: "t", "t | slice: 0" %}

    {% for g in grouped  %}
      <li><a href="#{{ g.name }}">{{ g.name | capitalize }}</a></li>
    {% endfor %}
  </ul>
</div>

<details style="margin-top: 1rem;">
  <summary>Click to show all tags:</summary>
  <div>
    {% for t in tag_words %}
      <a href="#{{ t | cgi_escape }}">{{ t }}</a>
    {% endfor %}
  </div>
</details>

{% assign all = site.documents %}

<!-- `tag_words` is a sorted array of the tag names. -->

{% for g in grouped %}
  <hr>
  <h2 id={{ g.name | slice: 0 }}>{{ g.name | capitalize }}</h2>
  {% for t in g.items %}
    <h3 id="{{ t | cgi_escape }}">{{ t }}</h3>
    <ul>
      {% assign tag_data = all | where_exp: "p", "p.tags contains t" %}
      {% for p in tag_data %}
        <li><a href="{{ p.url }}">{{ p.title }}</a></li>
      {% endfor %}
    </ul>
  {% endfor %}
{% endfor %}