2025-02-03 21:36:07 -05:00
|
|
|
use v6.e.PREVIEW;
|
|
|
|
|
|
|
|
use HTML::Functional;
|
|
|
|
use DB::BlogMeta;
|
2025-02-04 16:51:37 -05:00
|
|
|
use DB::Post;
|
2025-02-03 21:36:07 -05:00
|
|
|
|
|
|
|
unit class Config;
|
|
|
|
|
2025-02-04 16:51:37 -05:00
|
|
|
method generate-head(Str:D $title, BlogMeta:D $meta, $description?) {
|
|
|
|
head [
|
2025-02-03 21:36:07 -05:00
|
|
|
meta :charset<utf-8>;
|
|
|
|
meta :name<viewport>, :content<width=device-width, initial-scale=1>;
|
2025-02-04 16:51:37 -05:00
|
|
|
meta :author :content<Nathan McCarty>;
|
2025-02-03 21:51:09 -05:00
|
|
|
title "{$meta.title} — $title";
|
2025-02-04 16:51:37 -05:00
|
|
|
# Add description, if one exists
|
|
|
|
do if $description ~~ Str:D {
|
|
|
|
meta :description :content($description)
|
|
|
|
} else {
|
|
|
|
[]
|
|
|
|
}
|
|
|
|
# Preconnect to all our resource sources
|
|
|
|
link :rel<preconnect> :href<https://static.stranger.systems>;
|
2025-02-04 04:17:34 -05:00
|
|
|
link :rel<preconnect> :href<https://fonts.googleapis.com>;
|
|
|
|
link :rel<preconnect> :href<https://fonts.gstatic.com> :crossorigin;
|
2025-02-04 16:51:37 -05:00
|
|
|
# Load fonts, Iosevka Alie for code, and Open Sans for content
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href<https://static.stranger.systems/fonts/IosevkaAlie/IosevkaAile.css>;
|
2025-02-04 04:17:34 -05:00
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href<https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap>;
|
2025-02-04 16:51:37 -05:00
|
|
|
# Inline our style sheets
|
2025-02-04 03:18:19 -05:00
|
|
|
style %?RESOURCES<main.css>.slurp;
|
2025-02-04 03:10:40 -05:00
|
|
|
style %?RESOURCES<code.css>.slurp;
|
2025-02-03 21:36:07 -05:00
|
|
|
];
|
2025-02-04 16:51:37 -05:00
|
|
|
}
|
|
|
|
|
2025-02-04 21:39:47 -05:00
|
|
|
method site-header(BlogMeta:D $meta) {
|
|
|
|
header :class<site-header>, [
|
|
|
|
div :class<site-logo>, [
|
|
|
|
# TODO: Use a real image here
|
|
|
|
$meta.title
|
|
|
|
];
|
|
|
|
div :class<site-tagline>, [
|
|
|
|
$meta.tagline
|
|
|
|
];
|
|
|
|
div :class<header-links>, [
|
|
|
|
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2025-02-04 16:51:37 -05:00
|
|
|
# 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);
|
2025-02-03 21:51:09 -05:00
|
|
|
my $body =
|
|
|
|
body [
|
2025-02-04 21:39:47 -05:00
|
|
|
self.site-header: $meta;
|
2025-02-03 21:51:09 -05:00
|
|
|
div :class<post-body>, [
|
|
|
|
$content
|
|
|
|
]
|
|
|
|
];
|
|
|
|
# TODO: Setup footer
|
2025-02-03 21:36:07 -05:00
|
|
|
# my $footer;
|
|
|
|
|
|
|
|
my $html = html :lang<en>, [
|
|
|
|
$head,
|
|
|
|
$body
|
|
|
|
];
|
|
|
|
|
|
|
|
"<!doctype html>$html"
|
|
|
|
}
|