Add post source code tag

This commit is contained in:
Nathan McCarty 2025-02-10 12:27:05 -05:00
parent f887be396b
commit dcc6799e6f
5 changed files with 46 additions and 4 deletions

View file

@ -41,6 +41,8 @@ has Str:D @.slugs is json = [];
has Str:D @.tags is rw is json = [];
#| Should the post be hidden from the main list
has Bool:D $.hidden is json is rw = False;
#| An optional link to the source code for the post
has Str $.source-code is rw is json;
#| Get the title for this post, intended to be extracted from whatever
#| document produced it

View file

@ -82,6 +82,20 @@ sub post-tags(Post:D $post) is export {
}
}
sub post-source(Post:D $post) is export {
if $post.source-code {
div :class<post-source>, [
a :href($post.source-code), [
logo 'git';
'&nbsp;';
"Source Code";
];
]
} else {
[]
}
}
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"), [
@ -119,6 +133,7 @@ sub post-info(Int:D $id, Post:D $post, $db) is export {
post-edit $post;
post-read-time $post;
post-tags $post;
post-source $post;
post-series-tags $id, $post, $db;
];
}

View file

@ -47,6 +47,10 @@ sub icon($icon) is export {
i(:class("bx bx-$icon"))
}
sub logo($logo) is export {
i(:class("bx bxl-$logo"))
}
sub mins-to-string($mins) is export {
if $mins < 60 {
$mins.Str ~ "m"