aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2025-01-25 12:18:02 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2025-01-25 12:18:02 +0100
commit0403f2d5aeb1ce4e67fdbb30b65a728f80c1cc1f (patch)
treef508775c0b2ad8409a7e48c931ed09358d4a145c
parentf509e410bca55ff04b79b38a73e3751eff848c95 (diff)
add tag index
-rw-r--r--_includes/posts.html6
-rw-r--r--_includes/search.html6
-rw-r--r--_layouts/default.html1
-rw-r--r--_plugins/meta.rb23
-rw-r--r--_sass/layout.scss11
-rw-r--r--posts/style.scss7
-rw-r--r--readme.md4
-rw-r--r--tags.html28
8 files changed, 66 insertions, 20 deletions
diff --git a/_includes/posts.html b/_includes/posts.html
index 05eebe7..cdd9b47 100644
--- a/_includes/posts.html
+++ b/_includes/posts.html
@@ -1,10 +1,6 @@
<link rel="stylesheet" href="style.css">
-<form id="search" method="get" action="https://google.com/search">
- <input type="text" placeholder="search" name="q" spellcheck="false" autocomplete="off">
- <input type="hidden" name="q" value="site:{{ site.domain }}">
- <input type="submit">
-</form>
+{% include search.html %}
<table id="posts" class="plainlink">
<tr>
diff --git a/_includes/search.html b/_includes/search.html
new file mode 100644
index 0000000..cc8cd56
--- /dev/null
+++ b/_includes/search.html
@@ -0,0 +1,6 @@
+<form id="search" method="get" action="https://google.com/search">
+ <input type="text" placeholder="search" name="q" spellcheck="false" autocomplete="off">
+ <input type="hidden" name="q" value="site:{{ site.domain }}">
+ <input type="submit">
+</form>
+
diff --git a/_layouts/default.html b/_layouts/default.html
index 9c2204f..fa4902f 100644
--- a/_layouts/default.html
+++ b/_layouts/default.html
@@ -24,6 +24,7 @@
<div class="limitwidth">
<a href="/" class="item {% if page.id == "index" %}active{% endif %}">home</a>
<a href="/posts/by-date" class="item {% if page.id == "posts" %}active{% endif %}">posts</a>
+ <a href="/tags" class="item {% if page.id == "tags" %}active{% endif %}">tags</a>
<span class="right">
{% if page.toc %}<a href="#" class="item">top</a>{% endif %}
{% if page.post %}<a href="#footer" class="item">bottom</a>{% endif %}
diff --git a/_plugins/meta.rb b/_plugins/meta.rb
index d1d4a24..28afd13 100644
--- a/_plugins/meta.rb
+++ b/_plugins/meta.rb
@@ -3,7 +3,8 @@ class Meta < Jekyll::Generator
# convert yaml @0123456789 (unix timestamps) into ruby Date
site.data = parse_unix_dates(site.data)
- for page in site.collections['items'] do
+ posts = site.collections['items']
+ for page in posts do
# convert generated page metadata and add directly to `page.meta` in liquid
page.data['meta'] = transform_data(site, page.slug)
@@ -15,6 +16,9 @@ class Meta < Jekyll::Generator
# set page.date to generated date_initial
page.data['date'] = page.data['meta']['date']
end
+
+ # count tags on all posts
+ site.data['tags'] = count_tags(posts)
end
def parse_unix_dates(data)
@@ -43,4 +47,21 @@ class Meta < Jekyll::Generator
data['edits'] = git_log.length - 1 # original commit is not an edit
return data
end
+
+ def count_tags(posts)
+ tags = {}
+
+ # tally tags
+ for post in posts do
+ for tag in post.tags do
+ tags[tag] = tags.fetch(tag, 0) + 1
+ end
+ end
+
+ # sort by post count descending
+ tags = tags.sort_by {|key,value| -value}
+
+ return tags
+ end
end
+
diff --git a/_sass/layout.scss b/_sass/layout.scss
index 9666867..18ee411 100644
--- a/_sass/layout.scss
+++ b/_sass/layout.scss
@@ -67,11 +67,9 @@ aside ul {
aside > ul { margin-left: 12px; }
// align description arrow with list bullet inside toc
-aside summary { list-style-position: outside; }
-
+summary { list-style-position: outside; }
// hide bullets for list items that can be expanded
li.stub::marker { content: ""; }
-
// give collapsable element arrow "clickable" cursor
summary::marker { cursor: pointer; }
@@ -115,3 +113,10 @@ footer ul {
flex-grow: 1;
}
+#search {
+ display: flex;
+ gap: 6px;
+ margin: 24px 0px;
+}
+#search input[type=text] { flex-grow: 1; }
+
diff --git a/posts/style.scss b/posts/style.scss
index 532f491..b1a363f 100644
--- a/posts/style.scss
+++ b/posts/style.scss
@@ -17,10 +17,3 @@
// dates with table numerals
#posts td:nth-child(1) { font-feature-settings: "tnum"; }
-#search {
- display: flex;
- gap: 6px;
-
- margin-bottom: 24px;
-}
-#search input[type=text] { flex-grow: 1; }
diff --git a/readme.md b/readme.md
index 4b88963..f757713 100644
--- a/readme.md
+++ b/readme.md
@@ -2,7 +2,3 @@
Live at <https://blog.pipeframe.xyz>
-## TODO
-
-- tag index
-
diff --git a/tags.html b/tags.html
new file mode 100644
index 0000000..7892800
--- /dev/null
+++ b/tags.html
@@ -0,0 +1,28 @@
+---
+title: Tags
+layout: default
+id: tags
+toc: false
+post: false
+---
+
+<ul>
+ {% assign tags = site.data.tags %}
+ {% for tag in tags %}
+ <li class="stub">
+ <details>
+ <summary>
+ {{ tag[0] }} ({{ tag[1] }})
+ </summary>
+ <ul>
+ {% assign posts = site.items | where_exp: "post", "post.tags contains tag[0]" %}
+ {% for post in posts %}
+ <li><a href="{{ post.url }}">{{ post.title }}</a></li>
+ {% endfor %}
+ </ul>
+ </details>
+ </li>
+ {% endfor %}
+</ul>
+
+