Slug support
This commit is contained in:
parent
bb57f7f73e
commit
1d01a8986f
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue