Factor out generate-head
This commit is contained in:
parent
9a87e7825a
commit
68e20af5d7
3 changed files with 67 additions and 44 deletions
42
lib/Render/Head.rakumod
Normal file
42
lib/Render/Head.rakumod
Normal file
|
@ -0,0 +1,42 @@
|
|||
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 {
|
||||
head [
|
||||
meta :charset<utf-8>;
|
||||
meta :name<viewport>, :content<width=device-width, initial-scale=1>;
|
||||
meta :author :content<Nathan McCarty>;
|
||||
do if $title ~~ Str:D {
|
||||
title "$title — {$meta.title}";
|
||||
} else {
|
||||
title $meta.title;
|
||||
}
|
||||
# Add description, if one exists
|
||||
optl $description ~~ Str:D, -> {meta :description :content($description)};
|
||||
# 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>;
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue