Open graph tag generation for posts

This commit is contained in:
Nathan McCarty 2025-02-12 03:38:55 -05:00
parent 585b2be5ab
commit 2862f45d77
5 changed files with 40 additions and 26 deletions

View file

@ -2,6 +2,7 @@ use v6.e.PREVIEW;
unit module Render::Util;
use DB::Post;
use DB::BlogMeta;
use HTML::Functional;
@ -68,3 +69,14 @@ sub intersperse (\element, +list) is export {
take slip element, $_;
}
}
# get the link for a post
sub post-link-abs(BlogMeta:D $meta, Int:D $id, Post:D $post --> Str:D) is export {
my @slugs = $post.all-slugs;
my $base = $meta.get-base-url;
if @slugs.elems {
"$base/posts/by-slug/{@slugs[*-1]}.html"
} else {
"$base/posts/by-id/$id.html"
}
}