From 72607c7f25439328de9c5b8b9d8c5d0c10f01348 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Mon, 3 Feb 2025 20:41:31 -0500 Subject: [PATCH] add render method --- lib/DB/IdrisPost.rakumod | 6 ++++++ lib/DB/MarkdownPost.rakumod | 5 +++++ lib/DB/PlaceholderPost.rakumod | 8 ++++++++ lib/DB/Post.rakumod | 3 +++ 4 files changed, 22 insertions(+) diff --git a/lib/DB/IdrisPost.rakumod b/lib/DB/IdrisPost.rakumod index 850ff83..5dd6f9a 100644 --- a/lib/DB/IdrisPost.rakumod +++ b/lib/DB/IdrisPost.rakumod @@ -16,3 +16,9 @@ has Bool:D $.idris = True; method title(--> Str:D) { markdown-title($!source) } + +# Use katla to highlight our file, mangle the resulting output, and then pass it +# through to pandoc for html generation +method render-html(--> Str:D) { + die "Not implemented"; +} diff --git a/lib/DB/MarkdownPost.rakumod b/lib/DB/MarkdownPost.rakumod index 372fa31..e395949 100644 --- a/lib/DB/MarkdownPost.rakumod +++ b/lib/DB/MarkdownPost.rakumod @@ -15,3 +15,8 @@ has Bool:D $.markdown = True; method title(--> Str:D) { markdown-title($!source) } + +# Simply provide our source file to pandoc +method render-html(--> Str:D) { + die "Not implemented"; +} diff --git a/lib/DB/PlaceholderPost.rakumod b/lib/DB/PlaceholderPost.rakumod index e30d38b..a41e068 100644 --- a/lib/DB/PlaceholderPost.rakumod +++ b/lib/DB/PlaceholderPost.rakumod @@ -12,6 +12,9 @@ unit class PlaceholderPost does Post is json(:pretty); #| cheaty way has Bool:D $.placeholder = True; +#| An optional body for the placeholder post +has Str $.body; + method title(--> Str:D) { "Placeholder Article" } @@ -30,3 +33,8 @@ method empty(--> PlaceholderPost:D) { method all-slugs(--> Array[Str:D]) { Array[Str:D].new } + +# Return the body if there is one, the empty string if there isn't one +method render-html(--> Str:D) { + $!body // '' +} diff --git a/lib/DB/Post.rakumod b/lib/DB/Post.rakumod index 068affc..f27c2b6 100644 --- a/lib/DB/Post.rakumod +++ b/lib/DB/Post.rakumod @@ -50,3 +50,6 @@ method all-slugs(--> Array[Str:D]) { @slugs.push($long-title-slug); @slugs; } + +#| Render this post to an html body +method render-html(--> Str:D) {...}