Fix slugs logic
This commit is contained in:
parent
22952a01f7
commit
a8e3b30668
2 changed files with 5 additions and 2 deletions
1
blog
1
blog
|
@ -91,4 +91,5 @@ multi MAIN(
|
|||
);
|
||||
write-db $db-file, $db;
|
||||
say 'Post inserted with id ', $id;
|
||||
say 'Post has slugs: ', $db.posts{$id}.all-slugs;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ 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(--> Array[Str:D]) {
|
||||
my $long-title-slug = self.title.lc.subst: /\h*/, '-';
|
||||
return [$long-title-slug, @!slugs].flat.Array;
|
||||
my $long-title-slug = self.title.lc.trim.subst: /\h+/, '-', :g;
|
||||
my Str:D @slugs = @!slugs.clone;
|
||||
@slugs.push($long-title-slug);
|
||||
@slugs;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue