53 lines
2.1 KiB
HTML
53 lines
2.1 KiB
HTML
<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" />
|
|
{{ $hash := now.Unix }}
|
|
{{ $options := (dict "targetPath" (printf `minima.%d.css` $hash) "outputStyle" "compressed" "enableSourceMap" true) }}
|
|
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS $options }}
|
|
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
|
|
{{ $options = (dict "targetPath" (printf `minima.%d.js` $hash) "minify" true) }}
|
|
{{ $js := resources.Get "js/main.js" | js.Build $options | resources.ExecuteAsTemplate (printf `minima.%d.js` $hash) . }}
|
|
<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 }}
|
|
</head>
|
|
<script>
|
|
// We will default to system theme color if no choice was made.
|
|
let theme_2b_used = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
|
|
try {
|
|
if (!('theme' in localStorage)) {
|
|
const default_theme = '{{ .Site.Params.defaultTheme }}';
|
|
|
|
// For the first time entering this site, use the theme picked by the author.
|
|
if (default_theme === 'dark' || default_theme === 'light') {
|
|
theme_2b_used = default_theme;
|
|
}
|
|
|
|
// Remember the choice.
|
|
localStorage.theme = theme_2b_used;
|
|
}
|
|
|
|
document.querySelector('html').classList.add(localStorage.theme);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
</script>
|
|
|