Add series links

This commit is contained in:
Nathan McCarty 2025-02-09 02:43:22 -05:00
parent d170a2fccf
commit 4793d660e2
6 changed files with 54 additions and 10 deletions

View file

@ -61,6 +61,7 @@ sub site-header(BlogMeta:D $meta) is export {
header-link 'Index', '/index.html', 'home';
header-link 'Archive', '/archive.html', 'archive';
header-link 'Tags', '/tags.html', 'purchase-tag-alt';
header-link 'Series', '/series.html', 'book';
header-link 'About', '/about.html', 'info-circle';
header-link 'Feed', '/atom.xml', 'rss';
];

View file

@ -3,6 +3,7 @@ unit module Render::Post;
use Render::Util;
use DB::Post;
use DB::Series;
use HTML::Functional;
@ -81,20 +82,52 @@ sub post-tags(Post:D $post) is export {
}
}
sub post-info(Post:D $post) is export {
sub series-tag(Int:D $post-id, Int:D $series-id, Series:D $series) is export {
span :class<post-series-tag>, [
a :href("/series/$series-id.html"), [
icon 'book';
'&nbsp;';
span :class<post-series-tag-inner>, [
$series.title;
'&nbsp;';
'(';
($series.post-ids.first($post-id, :k) + 1).Str;
'/';
$series.post-ids.elems.Str;
')';
]
]
]
}
sub post-series-tags(Int:D $post-id, Post:D $post, $db) is export {
# Find all the series this post is in
my @series = $db.series.grep(*.value.contains-post: $post-id);
if @series {
div :class<post-series-tags>,
@series.map(-> $pair {
series-tag $post-id, $pair.key, $pair.value
});
} else {
[]
}
}
sub post-info(Int:D $id, Post:D $post, $db) is export {
div :class<post-info>, [
post-date $post;
post-edit $post;
post-read-time $post;
post-tags $post;
post-series-tags $id, $post, $db;
];
}
sub post-header(Post:D $post) is export {
sub post-header(Int:D $id, Post:D $post, $db) is export {
header :class<post-header>, [
div :class<post-title>, [
h1 $post.title;
];
post-info $post;
post-info $id, $post, $db;
]
}