Description generation

This commit is contained in:
Nathan McCarty 2025-02-04 16:51:37 -05:00
parent 804b51aaa6
commit ce364c01d8
6 changed files with 102 additions and 33 deletions

View file

@ -11,6 +11,9 @@ unit class MarkdownPost does Post is json(:pretty);
#| cheaty way
has Bool:D $.markdown = True;
#| Override the generated description for this post
has Str $.summary;
method title(--> Str:D) {
markdown-title $!source
}
@ -19,3 +22,13 @@ method title(--> Str:D) {
method render-html(--> Str:D) {
markdown-to-html $!source
}
# Return our summary, if we have one, otherwise extract the first paragraph of
# the markdown document
method description(--> Str) {
if $!summary {
$!summary
} else {
markdown-first-paragraph $!source
}
}