use v6.e.PREVIEW;
use HTML::Functional;
use DB::BlogMeta;
use DB::Post;
unit class Config;
method generate-head(Str:D $title, BlogMeta:D $meta, $description?) {
head [
meta :charset;
meta :name, :content;
meta :author :content;
title "{$meta.title} — $title";
# Add description, if one exists
do if $description ~~ Str:D {
meta :description :content($description)
} else {
[]
}
# Preconnect to all our resource sources
link :rel :href;
link :rel :href;
link :rel :href :crossorigin;
# Load fonts, Iosevka Alie for code, and Open Sans for content
link :rel,
:href;
link :rel,
:href;
# Inline our style sheets
style %?RESOURCES.slurp;
style %?RESOURCES.slurp;
];
}
method site-header(BlogMeta:D $meta) {
header :class, [
div :class, [
# TODO: Use a real image here
$meta.title
];
div :class, [
$meta.tagline
];
div :class, [
]
]
}
# TODO: Support GFM admonitions
method generate-post(Post:D $post, BlogMeta:D $meta) {
my $content = $post.render-html;
my $head = self.generate-head($post.title, $meta, $post.description);
my $body =
body [
self.site-header: $meta;
div :class, [
$content
]
];
# TODO: Setup footer
# my $footer;
my $html = html :lang, [
$head,
$body
];
"$html"
}