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

48 lines
1.9 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">
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{ template "_internal/google_analytics.html" . }}
<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>
{{ $favicon := "favicon.ico" }}
<link rel="shortcut icon" href="{{ $favicon | relURL }}" type="image/x-icon" />
2021-08-05 10:30:29 +02:00
{{ $hash := now.Unix }}
{{ $options := (dict "targetPath" (printf `minima.%d.css` $hash) "outputStyle" "compressed" "enableSourceMap" true) }}
2022-11-08 11:07:48 +01:00
{{ $style := resources.Get "css/main.scss" | resources.ToCSS $options }}
2021-08-05 10:30:29 +02:00
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
{{ $options = (dict "targetPath" (printf `minima.%d.js` $hash) "minify" true) }}
2021-11-26 18:48:40 +01:00
{{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate (printf `minima.%d.js` $hash) . }}
2021-08-19 06:42:47 +02:00
<script defer type="text/javascript" src="{{ $js.RelPermalink }}"></script>
{{ if .IsTranslated }}
{{ range .Translations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" title="{{ .Language.LanguageName }}">
{{ end }}
{{ end }}
2021-07-18 10:34:01 +02:00
</head>
<script>
2022-11-09 09:03:19 +01:00
// default to system color scheme.
2022-11-09 13:51:50 +01:00
let default_theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
2021-07-18 10:34:01 +02:00
try {
2022-11-09 13:51:50 +01:00
const local = localStorage.getItem('theme')
if (local) {
default_theme = local
}
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>