hugo-theme-minima/layouts/partials/head.html

69 lines
3.1 KiB
HTML
Raw Normal View History

2021-07-18 10:34:01 +02:00
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2023-05-12 14:30:35 +02:00
{{ if hugo.IsProduction }}
2021-07-18 10:34:01 +02:00
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{ template "_internal/google_analytics.html" . }}
2023-05-12 14:30:35 +02:00
{{ end }}
2021-07-18 10:34:01 +02:00
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#262d33">
<title>
{{ if .IsHome }}
{{ .Site.Title }} {{ if .Site.Params.subtitle }} - {{ .Site.Params.subtitle }} {{ end }}
{{ else }}
{{ .Site.Title }} - {{ .Title }}
{{ end }}
</title>
2023-05-12 14:30:35 +02:00
<!-- favicon -->
2021-07-18 10:34:01 +02:00
{{ $favicon := "favicon.ico" }}
<link rel="shortcut icon" href="{{ $favicon | relURL }}" type="image/x-icon" />
2023-05-12 14:30:35 +02:00
<!-- styles -->
2023-03-15 17:22:34 +01:00
{{ $options := (dict "targetPath" "minima.css" "outputStyle" "compressed" "enableSourceMap" true) }}
2023-05-12 14:30:35 +02:00
{{ $style := resources.Get "css/main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS $options | fingerprint }}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" integrity="{{ $style.Data.Integrity }}">
<!-- scripts -->
{{ $options = (dict "targetPath" "minima.js" "minify" true "params" site.Params) }}
{{ $script := resources.Get "js/main.js" | js.Build $options | fingerprint }}
<script defer type="text/javascript" src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
{{ if and .Site.Params.search.enable (eq .Layout "search") }}
{{ $options = (dict "minify" true "params" site.Params) }}
{{ $search := resources.Get "js/search.js" | js.Build $options}}
{{ $fusejs := resources.Get "js/min/fuse.basic.min.js" }}
{{ $script := (slice $fusejs $search) | resources.Concat "assets/js/search.js" | fingerprint }}
<script defer crossorigin="anonymous" src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>
{{ end }}
<!-- i18n -->
{{ if .IsTranslated }}
{{ range .Translations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" title="{{ .Language.LanguageName }}">
{{ end }}
{{ end }}
2023-05-06 02:27:28 +02:00
<!-- Umami Analytics -->
{{ if eq .Site.Params.analytics.provider "umami" }}
{{ with .Site.Params.analytics.umami }}
<script async src="{{ .server }}/script.js" data-website-id="{{ .websiteID }}"></script>
{{ end }}
{{ end }}
2024-05-19 13:26:26 +02:00
<link rel="stylesheet" href="https://assets.codeword.info/fonts/MiSans/include.css">
2021-07-18 10:34:01 +02:00
</head>
<script>
2022-11-09 09:03:19 +01:00
// default to system color scheme.
2023-04-10 15:37:53 +02:00
const default_theme_config = '{{ .Site.Params.defaultTheme }}'
const default_light_theme = default_theme_config === 'system' ? 'light' : default_theme_config;
let default_theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : default_light_theme;
2021-07-18 10:34:01 +02:00
try {
2023-04-10 15:37:53 +02:00
const saved_theme = localStorage.getItem('theme')
if (saved_theme) {
default_theme = saved_theme === default_light_theme ? saved_theme : default_light_theme;
2022-11-09 13:51:50 +01:00
}
localStorage.setItem('theme', default_theme);
window.minima_theme = default_theme;
document.querySelector('html').classList.add(default_theme);
2021-07-18 10:34:01 +02:00
} catch (e) {
console.error(e);
}
2021-11-12 08:47:28 +01:00
</script>