From 900bb5e845c3ad44defbd427cae3d44a4a43321f Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 25 Feb 2023 13:15:44 +0100 Subject: feat: Initial commit --- .../layouts/partials/head/custom-head.html | 1 + code/frontpage/layouts/partials/head/favicons.html | 9 + code/frontpage/layouts/partials/head/head.html | 11 ++ .../frontpage/layouts/partials/head/opengraph.html | 69 +++++++ .../layouts/partials/head/resource-hints.html | 4 + .../layouts/partials/head/script-header.html | 8 + code/frontpage/layouts/partials/head/seo.html | 48 +++++ .../layouts/partials/head/structured-data.html | 210 +++++++++++++++++++++ .../layouts/partials/head/stylesheet.html | 11 ++ .../layouts/partials/head/twitter_cards.html | 24 +++ 10 files changed, 395 insertions(+) create mode 100644 code/frontpage/layouts/partials/head/custom-head.html create mode 100644 code/frontpage/layouts/partials/head/favicons.html create mode 100644 code/frontpage/layouts/partials/head/head.html create mode 100644 code/frontpage/layouts/partials/head/opengraph.html create mode 100644 code/frontpage/layouts/partials/head/resource-hints.html create mode 100644 code/frontpage/layouts/partials/head/script-header.html create mode 100644 code/frontpage/layouts/partials/head/seo.html create mode 100644 code/frontpage/layouts/partials/head/structured-data.html create mode 100644 code/frontpage/layouts/partials/head/stylesheet.html create mode 100644 code/frontpage/layouts/partials/head/twitter_cards.html (limited to 'code/frontpage/layouts/partials/head') diff --git a/code/frontpage/layouts/partials/head/custom-head.html b/code/frontpage/layouts/partials/head/custom-head.html new file mode 100644 index 0000000..0c59d7f --- /dev/null +++ b/code/frontpage/layouts/partials/head/custom-head.html @@ -0,0 +1 @@ + diff --git a/code/frontpage/layouts/partials/head/favicons.html b/code/frontpage/layouts/partials/head/favicons.html new file mode 100644 index 0000000..93c5ed5 --- /dev/null +++ b/code/frontpage/layouts/partials/head/favicons.html @@ -0,0 +1,9 @@ + + +{{ if os.FileExists "static/favicon.svg" -}} + +{{ end -}} + + + + diff --git a/code/frontpage/layouts/partials/head/head.html b/code/frontpage/layouts/partials/head/head.html new file mode 100644 index 0000000..12e2a8c --- /dev/null +++ b/code/frontpage/layouts/partials/head/head.html @@ -0,0 +1,11 @@ + + + + + {{ block "head/resource-hints" . }}{{ partial "head/resource-hints.html" . }}{{ end }} + {{ block "head/script-header" . }}{{ partial "head/script-header.html" . }}{{ end }} + {{ block "head/stylesheet" . }}{{ partial "head/stylesheet.html" . }}{{ end }} + {{ block "head/seo" . }}{{ partial "head/seo.html" . }}{{ end }} + {{ block "head/favicons" . }}{{ partial "head/favicons.html" . }}{{ end }} + {{ block "head/custom-head" . }}{{ partial "head/custom-head.html" . }}{{ end }} + diff --git a/code/frontpage/layouts/partials/head/opengraph.html b/code/frontpage/layouts/partials/head/opengraph.html new file mode 100644 index 0000000..6127e82 --- /dev/null +++ b/code/frontpage/layouts/partials/head/opengraph.html @@ -0,0 +1,69 @@ + + + + +{{ if $.Scratch.Get "paginator" -}} + {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}} + +{{ else -}} + +{{ end -}} +{{ with .Site.Params.title -}} + +{{ end -}} + +{{ $iso8601 := "2006-01-02T15:04:05-07:00" -}} +{{ if .IsPage -}} + {{ if not .PublishDate.IsZero -}} + + {{ else if not .Date.IsZero -}} + + {{ end -}} + {{ if not .Lastmod.IsZero -}} + + {{ end -}} +{{ else -}} + {{ if not .Date.IsZero -}} + + {{ end -}} +{{ end -}} + +{{ if eq .Kind "home" -}} + {{ .Scratch.Set "title" .Site.Params.titleHome -}} +{{ else -}} + {{ .Scratch.Set "title" .Title -}} +{{ end -}} + +{{ with $.Params.images -}} + {{ range first 6 . -}} + + {{ end -}} +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end -}} + {{ with $featured -}} + + {{ else -}} + {{ with $.Site.Params.images -}} + + + {{ end -}} + {{ end -}} +{{ end -}} + +{{ with $.Site.Params.images -}} + {{ $.Scratch.Set "primaryImage" (index . 0 | absURL) -}} +{{ end -}} + +{{ with .Params.audio -}} + +{{ end -}} + +{{ with .Params.videos -}} + {{ range . -}} + + {{ end -}} +{{ end -}} diff --git a/code/frontpage/layouts/partials/head/resource-hints.html b/code/frontpage/layouts/partials/head/resource-hints.html new file mode 100644 index 0000000..6ebcdeb --- /dev/null +++ b/code/frontpage/layouts/partials/head/resource-hints.html @@ -0,0 +1,4 @@ +{{ if .Site.Params.options.kaTex -}} + + +{{ end -}} \ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/script-header.html b/code/frontpage/layouts/partials/head/script-header.html new file mode 100644 index 0000000..38e5b5b --- /dev/null +++ b/code/frontpage/layouts/partials/head/script-header.html @@ -0,0 +1,8 @@ +{{ if .Site.Params.options.darkMode -}} + {{ $darkModeInit := resources.Get "js/darkmode-init.js" | js.Build | minify -}} + +{{ end -}} +{{- if and (.Site.Params.alert) (.Site.Params.alertDismissable) -}} + {{ $alertInit := resources.Get "js/alert-init.js" | js.Build | minify -}} + +{{- end -}} \ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/seo.html b/code/frontpage/layouts/partials/head/seo.html new file mode 100644 index 0000000..ac31d72 --- /dev/null +++ b/code/frontpage/layouts/partials/head/seo.html @@ -0,0 +1,48 @@ +{{ if eq .Kind "404" -}} + +{{ else -}} + {{ with .Params.robots -}} + + {{ else -}} + + + + {{ end -}} +{{ end -}} + +{{ if .IsHome -}} + {{ .Site.Params.title }} {{ .Site.Params.titleSeparator }} {{ .Site.Params.titleAddition }} +{{ else -}} + {{ .Title }} {{ .Site.Params.titleSeparator }} {{ .Site.Params.title }} +{{ end -}} + +{{ with .Description -}} + +{{ else -}} + {{ with .Summary | plainify -}} + + {{ else -}} + + {{ end -}} +{{ end -}} + +{{ if $.Scratch.Get "paginator" }} + + {{ if .Paginator.HasPrev -}} + + {{ end -}} + {{ if .Paginator.HasNext -}} + + {{ end -}} +{{ else -}} + +{{ end -}} + +{{ partial "head/opengraph.html" . }} +{{ partial "head/twitter_cards.html" . }} + +{{ range .AlternativeOutputFormats -}} + +{{ end -}} + +{{ partial "head/structured-data.html" . }} diff --git a/code/frontpage/layouts/partials/head/structured-data.html b/code/frontpage/layouts/partials/head/structured-data.html new file mode 100644 index 0000000..1f153a3 --- /dev/null +++ b/code/frontpage/layouts/partials/head/structured-data.html @@ -0,0 +1,210 @@ +{{ $baseURL := "/" | absURL -}} + +{{ $dot := . -}} +{{ $dot.Scratch.Set "path" "" -}} +{{ $dot.Scratch.Set "breadcrumb" slice -}} + +{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} +{{ $.Scratch.Add "path" .Site.BaseURL -}} + +{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} + {{ range $index, $element := split $url "/" -}} + {{ $dot.Scratch.Add "path" $element -}} + {{ $.Scratch.Add "path" "/" -}} + {{ if ne $element "" -}} + {{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}} + {{ end -}} +{{ end -}} + + \ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/stylesheet.html b/code/frontpage/layouts/partials/head/stylesheet.html new file mode 100644 index 0000000..4dc25c0 --- /dev/null +++ b/code/frontpage/layouts/partials/head/stylesheet.html @@ -0,0 +1,11 @@ +{{ if eq (hugo.Environment) "development" -}} + {{ $options := (dict "targetPath" "main.css" "enableSourceMap" true "includePaths" (slice "node_modules")) -}} + {{ $css := resources.Get "scss/app.scss" | toCSS $options -}} + +{{ else -}} + {{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "includePaths" (slice "node_modules")) -}} + {{ $css := resources.Get "scss/app.scss" | toCSS $options | postCSS (dict "config" "config/postcss.config.js") -}} + {{ $secureCSS := $css | resources.Fingerprint "sha512" -}} + +{{ end -}} + \ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/twitter_cards.html b/code/frontpage/layouts/partials/head/twitter_cards.html new file mode 100644 index 0000000..fdf581c --- /dev/null +++ b/code/frontpage/layouts/partials/head/twitter_cards.html @@ -0,0 +1,24 @@ + + + + + +{{ with $.Params.images -}} + +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}} + {{ end -}} + {{ with $featured -}} + + {{ else -}} + {{ with $.Site.Params.images -}} + + {{ else -}} + + {{ end -}} + {{ end -}} +{{ end -}} + \ No newline at end of file -- cgit v1.3