diff --git a/lib/DB.rakumod b/lib/DB.rakumod index b35568e..e56ec67 100644 --- a/lib/DB.rakumod +++ b/lib/DB.rakumod @@ -71,6 +71,12 @@ class PostDB { #| Render the site to the provided output directory method render(IO::Path:D $out-dir, Config:D :$config = Config.new) { + ## Consistency checks + # Check to make sure all the slugs are unique + my @all-the-slugs = %!posts.values.map(*.all-slugs).flat; + die "Duplicate slug detected" + unless @all-the-slugs.unique.elems == @all-the-slugs.elems; + ## Rendering my $posts = $out-dir.add('posts/'); my $by-id = $posts.add('by-id/'); my $by-slug = $posts.add('by-slug/'); diff --git a/lib/DB/Post.rakumod b/lib/DB/Post.rakumod index 42132f6..246753e 100644 --- a/lib/DB/Post.rakumod +++ b/lib/DB/Post.rakumod @@ -63,7 +63,8 @@ method all-slugs(--> Array[Str:D]) { my Str:D @slugs = @!slugs.clone; @slugs.push($long-title-slug); @slugs.push($six-word-slug); - @slugs; + @slugs.=unique; + @slugs } #| Render this post to an html body