From 2072f88711ecde661c4eca9b04e5836724b104a8 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Fri, 7 Feb 2025 01:58:44 -0500 Subject: [PATCH] Generate pages for individual tags --- lib/Config.rakumod | 16 ++++++++++++++++ lib/DB.rakumod | 6 ++++++ resources/colors.css | 14 ++++++++++---- resources/main.css | 6 +++--- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/Config.rakumod b/lib/Config.rakumod index 58d7b7d..6fd7525 100644 --- a/lib/Config.rakumod +++ b/lib/Config.rakumod @@ -370,6 +370,22 @@ method generate-tags-page($db, @tags) { "$html" } +method generate-tag-page($db, $tag) { + my $head = self.generate-head(Nil, $db.meta); + my $body = body [ + self.site-header: $db.meta; + self.generate-tag-blurb($db, $tag, 4); + ]; + + my $html = + html :lang, [ + $head, + $body + ]; + + "$html" +} + sub icon($icon) { i(:class("bx bx-$icon")) } diff --git a/lib/DB.rakumod b/lib/DB.rakumod index 87614e4..88a1140 100644 --- a/lib/DB.rakumod +++ b/lib/DB.rakumod @@ -108,6 +108,12 @@ class PostDB { # Generate the tags pages my @tags = %!posts.values.map(*.tags).flat.unique; $out-dir.add('tags.html').spurt: $config.generate-tags-page(self, @tags); + my $tags-dir = $out-dir.add('tags/'); + mkdir $tags-dir unless $tags-dir.e; + for @tags -> $tag { + $tags-dir.add("$tag.html").spurt: + $config.generate-tag-page(self, $tag); + } # Render the rss/atom feed my $atom-path = $out-dir.add('atom.xml'); my $atom = posts-to-atom self; diff --git a/resources/colors.css b/resources/colors.css index fb8f588..bfd642f 100644 --- a/resources/colors.css +++ b/resources/colors.css @@ -53,16 +53,22 @@ a:visited { .site-tagline { color: var(--dim-0); } -.post-body, .post-header, .post-blurbs, .tags, .tag-blurb-post { +.post-body, .post-header, .post-blurbs, .tags, .tags .tag-blurb-post { background-color: var(--bg-0); } -.post-blurb, .tag-blurb { +.post-blurb, .tags .tag-blurb { background-color: var(--bg-1); } -.post-title, .post-blurbs > h1 { +:not(.tags) .tag-blurb { + background-color: var(--bg-0); +} +:not(.tags) .tag-blurb-post { + background-color: var(--bg-1); +} +.post-title, .post-blurbs h1 { color: var(--green); } -.post-body > h2, .post-body > h3, .post-body > h4 { +.post-body h2, .post-body h3, .post-body h4 { color: var(--fg-1); } blockquote { diff --git a/resources/main.css b/resources/main.css index 5958cec..a23b136 100644 --- a/resources/main.css +++ b/resources/main.css @@ -83,11 +83,11 @@ body, .post { border-radius: var(--box-radius); box-sizing: border-box; } -.post-body > p { +.post-body p { margin: auto var(--box-margin-horz); align-self: stretch; } -.post-title > h1 { +.post-title h1 { margin-top: 0px; margin-bottom: 0px; } @@ -102,7 +102,7 @@ body, .post { .post-read-time { text-decoration: underline dotted; } -.post-body > h2, .post-body > h3, .post-body > h4 { +.post-body h2, .post-body h3, .post-body h4 { text-align: center; } .post-blurbs {