Slug support

This commit is contained in:
Nathan McCarty 2025-01-21 21:58:10 -05:00
parent bb57f7f73e
commit 1d01a8986f

View file

@ -13,11 +13,20 @@ role Post is json {
#| The time to display for the creation of the post
has DateTime:D $.posted-at is required;
#| An optional list of edit times for the post
has DateTime:D @.edited-at is rw = [];
has DateTime:D @.edited-at = [];
#| An optional list of extra slugs to use for this post
has Str:D @.slugs = [];
#| Get the title for this post, intended to be extracted from whatever
#| document produced it
method title(--> Str:D) {...}
#| Get the list of slugs for this post, including ones auto generated from
#| the title, as well as any additional slugs
method all-slugs(--> List[Str:D]) {
my $long-title-slug = self.title.lc.subst: /\h*/, '-';
return [$long-title-slug, @!slugs].flat.list;
}
}
#| A plain markdown post