Repository navigation
Expand file tree
/
Copy pathtags.pug
More file actions
123 lines (113 loc) · 5.84 KB
/
Copy pathtags.pug
File metadata and controls
123 lines (113 loc) · 5.84 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
layout: default
title: Tags
description: Browse posts and projects by topic
permalink: /tags/
hero: true
---
.hero
div
h1 {{ page.title }}
p.excerpt {{ page.description }}
main.container.mx-auto.px-4.py-8
.max-w-4xl.mx-auto
//- Collect unique tags. Posts use Jekyll's built-in site.tags index so the
//- page does not rescan every post for every tag during build.
| {% assign all_tags = "" | split: "" %}
| {% for tag_pair in site.tags %}
| {% assign tag = tag_pair[0] %}
| {% unless all_tags contains tag %}
| {% assign all_tags = all_tags | push: tag %}
| {% endunless %}
| {% endfor %}
| {% for project in site.projects %}
| {% for tag in project.tags %}
| {% unless all_tags contains tag %}
| {% assign all_tags = all_tags | push: tag %}
| {% endunless %}
| {% endfor %}
| {% endfor %}
| {% for article in site.knowledge %}
| {% for tag in article.tags %}
| {% unless all_tags contains tag %}
| {% assign all_tags = all_tags | push: tag %}
| {% endunless %}
| {% endfor %}
| {% endfor %}
| {% assign sorted_tags = all_tags | sort_natural %}
//- Build count-prefixed array for sorting tag cloud by count.
//- Liquid lacks sort_by for computed values, so we zero-pad counts
//- (e.g. "007:gptme") and use string sort + reverse to get descending order.
| {% assign counted_tags = "" | split: "" %}
| {% for tag in sorted_tags %}
| {% assign tag_count = 0 %}
| {% for tag_pair in site.tags %}
| {% if tag_pair[0] == tag %}
| {% for post in tag_pair[1] %}{% assign tag_count = tag_count | plus: 1 %}{% endfor %}
| {% endif %}
| {% endfor %}
| {% for project in site.projects %}
| {% if project.tags contains tag %}{% assign tag_count = tag_count | plus: 1 %}{% endif %}
| {% endfor %}
| {% for article in site.knowledge %}
| {% if article.tags contains tag %}{% assign tag_count = tag_count | plus: 1 %}{% endif %}
| {% endfor %}
| {% if tag_count < 10 %}{% assign padded = tag_count | prepend: "00" %}{% elsif tag_count < 100 %}{% assign padded = tag_count | prepend: "0" %}{% else %}{% assign padded = tag_count %}{% endif %}
| {% assign entry = padded | append: ":" | append: tag %}
| {% assign counted_tags = counted_tags | push: entry %}
| {% endfor %}
| {% assign counted_tags_sorted = counted_tags | sort | reverse %}
//- Tag cloud at top, sorted by count (most-used first).
.flex.flex-wrap.gap-2.mb-12.justify-center
| {% for entry in counted_tags_sorted %}
| {% assign parts = entry | split: ":" %}
| {% assign tag_count = parts[0] | plus: 0 %}
| {% assign tag = parts | slice: 1, 99 | join: ":" %}
| {% assign tag_anchor = tag | slugify %}
a.inline-flex.items-center.gap-1.no-underline.rounded-lg.transition-colors(href="#{{ tag_anchor }}" class="px-3 py-1.5 bg-surface border border-border hover:border-primary hover:text-primary text-text/70 text-sm")
| \#{{ tag }}
span.text-xs(class="text-text/40") {{ tag_count }}
| {% endfor %}
//- Per-tag sections (sorted alphabetically).
//- Each section lists projects first (labeled "project"), then posts by date.
| {% for tag in sorted_tags %}
| {% assign tag_anchor = tag | slugify %}
section.mb-10(id="{{ tag_anchor }}")
.flex.items-baseline.gap-3.mb-4.pb-2.border-b.border-border
h2.text-xl.font-bold.m-0.text-primary \#{{ tag }}
| {% assign tag_count = 0 %}
| {% for tag_pair in site.tags %}{% if tag_pair[0] == tag %}{% for post in tag_pair[1] %}{% assign tag_count = tag_count | plus: 1 %}{% endfor %}{% endif %}{% endfor %}
| {% for project in site.projects %}{% if project.tags contains tag %}{% assign tag_count = tag_count | plus: 1 %}{% endif %}{% endfor %}
| {% for article in site.knowledge %}{% if article.tags contains tag %}{% assign tag_count = tag_count | plus: 1 %}{% endif %}{% endfor %}
span.text-sm(class="text-text/40") {{ tag_count }} items
//- Projects with this tag
| {% for project in site.projects %}
| {% if project.tags contains tag %}
article.flex.items-baseline.gap-4.py-2(class="hover:bg-surface/30 -mx-3 px-3 rounded transition-colors")
span.text-xs.font-medium.uppercase.tracking-wider.flex-shrink-0.w-16(class="text-text/30") project
div
a.text-base.font-semibold.no-underline(href="{{ project.url }}" class="text-text hover:text-primary transition-colors") {{ project.title }}
| {% if project.excerpt %}
span.text-sm.ml-2(class="text-text/50") — {{ project.excerpt | truncatewords: 12 }}
| {% endif %}
| {% endif %}
| {% endfor %}
//- Posts with this tag
| {% for tag_pair in site.tags %}
| {% if tag_pair[0] == tag %}
| {% for post in tag_pair[1] %}
article.flex.items-baseline.gap-4.py-2(class="hover:bg-surface/30 -mx-3 px-3 rounded transition-colors")
time.text-xs.whitespace-nowrap.flex-shrink-0.w-16(class="text-text/40") {{ post.date | date: "%b %Y" }}
a.text-base.no-underline(href="{{ post.url }}" class="text-text hover:text-primary transition-colors") {{ post.title }}
| {% endfor %}
| {% endif %}
| {% endfor %}
//- Wiki articles with this tag
| {% for article in site.knowledge %}
| {% if article.tags contains tag %}
article.flex.items-baseline.gap-4.py-2(class="hover:bg-surface/30 -mx-3 px-3 rounded transition-colors")
span.text-xs.font-medium.uppercase.tracking-wider.flex-shrink-0.w-16(class="text-text/30") wiki
a.text-base.no-underline(href="{{ article.url }}" class="text-text hover:text-primary transition-colors") {{ article.title }}
| {% endif %}
| {% endfor %}
| {% endfor %}