2025-02-07 02:26:17 -05:00
|
|
|
use v6.e.PREVIEW;
|
|
|
|
unit module Render::Head;
|
|
|
|
|
|
|
|
use HTML::Functional;
|
|
|
|
|
|
|
|
use Render::Util;
|
|
|
|
use DB::BlogMeta;
|
|
|
|
|
|
|
|
sub generate-head(BlogMeta:D $meta, $title?, $description?) is export {
|
2025-02-12 03:38:55 -05:00
|
|
|
my $final-title = do if $title ~~ Str:D {
|
|
|
|
"$title — {$meta.title}"
|
|
|
|
} else {
|
|
|
|
$meta.title
|
|
|
|
};
|
|
|
|
[
|
2025-02-07 02:26:17 -05:00
|
|
|
meta :charset<utf-8>;
|
|
|
|
meta :name<viewport>, :content<width=device-width, initial-scale=1>;
|
|
|
|
meta :author :content<Nathan McCarty>;
|
2025-02-12 03:38:55 -05:00
|
|
|
title $final-title;
|
2025-02-07 02:26:17 -05:00
|
|
|
# Add description, if one exists
|
2025-02-12 03:38:55 -05:00
|
|
|
optl $description ~~ Str:D, -> {meta :description :content(^ $description)};
|
2025-02-07 02:26:17 -05:00
|
|
|
# Preconnect to all our resource sources
|
|
|
|
link :rel<preconnect> :href<https://static.stranger.systems>;
|
|
|
|
link :rel<preconnect> :href<https://fonts.googleapis.com>;
|
|
|
|
link :rel<preconnect> :href<https://fonts.gstatic.com> :crossorigin;
|
|
|
|
link :rel<preconnect> :href<https://unpkg.com>;
|
|
|
|
# Load fonts, Iosevka for code, Open Sans for content, and boxicons for
|
|
|
|
# icons
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href<https://static.stranger.systems/fonts/Iosevka/Iosevka.css>;
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href<https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap>;
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href<https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css>;
|
|
|
|
# Link our style sheets
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href</resources/colors.css>;
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href</resources/main.css>;
|
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href</resources/code.css>;
|
2025-02-09 07:31:26 -05:00
|
|
|
link :rel<stylesheet>,
|
|
|
|
:href</resources/admonitions.css>;
|
2025-02-12 05:48:08 -05:00
|
|
|
# Tell dark reader that we'll behave
|
|
|
|
meta :name<color-scheme>, :content<light dark>;
|
2025-02-12 20:48:24 -05:00
|
|
|
# Tell feed readers about our feed
|
|
|
|
link :rel<alternate>, :type<application/atom+xml>, :title($meta.title),
|
|
|
|
:href</feed.xml>;
|
2025-02-07 02:26:17 -05:00
|
|
|
]
|
|
|
|
}
|
2025-02-07 02:44:35 -05:00
|
|
|
|
|
|
|
sub site-header(BlogMeta:D $meta) is export {
|
|
|
|
sub header-link($name, $path, $icon) {
|
|
|
|
a :href("$path"), [
|
|
|
|
icon $icon;
|
|
|
|
span $name;
|
|
|
|
]
|
|
|
|
}
|
|
|
|
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>, [
|
|
|
|
header-link 'Index', '/index.html', 'home';
|
2025-02-09 03:22:30 -05:00
|
|
|
header-link 'All Posts', '/archive.html', 'archive';
|
2025-02-07 02:44:35 -05:00
|
|
|
header-link 'Tags', '/tags.html', 'purchase-tag-alt';
|
2025-02-09 02:43:22 -05:00
|
|
|
header-link 'Series', '/series.html', 'book';
|
2025-02-07 02:44:35 -05:00
|
|
|
header-link 'About', '/about.html', 'info-circle';
|
|
|
|
header-link 'Feed', '/atom.xml', 'rss';
|
|
|
|
];
|
|
|
|
]
|
|
|
|
}
|