1
0
Fork 0
hugo-paper/layouts/partials/header.html

115 lines
3.8 KiB
HTML
Raw Normal View History

2018-01-08 17:28:39 +01:00
<!DOCTYPE html>
2021-08-20 13:21:20 +02:00
<html lang="{{ site.LanguageCode }}">
2019-03-31 14:32:06 +02:00
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
2021-08-20 13:21:20 +02:00
2019-03-31 14:32:06 +02:00
<!-- Title -->
2021-08-20 13:21:20 +02:00
<title>{{ if not .IsHome }}{{ .Title }} - {{ end }}{{ site.Title }}</title>
2019-03-31 14:32:06 +02:00
<!-- Meta -->
2021-08-20 13:21:20 +02:00
{{ if eq .Kind "page" }}
2019-03-31 14:32:06 +02:00
<meta name="description" content="{{ .Summary }}">
2021-08-20 13:21:20 +02:00
<meta name="author" content="{{ .Params.Author | default site.Author.name }}">
{{ else }}
<meta name="description" content="{{ site.Params.description }}">
<meta name="author" content="{{ site.Author.name }}">
{{ end }}
<!-- Styles & Scripts -->
{{ $app_css := resources.Get "app.css" }}
{{ $custom_css := resources.Get "custom.css" }}
{{ $css := slice $app_css $custom_css | resources.Concat "app.css" | minify }}
<link rel="preload stylesheet" as="style" href="{{ $css.Permalink }}">
{{ if and .IsPage (not site.Params.disableHLJS) }}
<link rel="preload stylesheet" as="style" href="{{ `an-old-hope.min.css` | absURL }}">
<script defer src="{{ `highlight.min.js` | absURL }}" onload="hljs.initHighlightingOnLoad();"></script>
{{ end }}
2019-03-31 14:32:06 +02:00
<!-- Favicons -->
2021-08-20 13:21:20 +02:00
<link rel="icon" href="{{ `favicon.ico` | absURL }}">
<link rel="apple-touch-icon" href="{{ `apple-touch-icon.png` | absURL }}">
2019-03-31 14:32:06 +02:00
<!-- Generator -->
2021-08-20 13:21:20 +02:00
{{ hugo.Generator }}
2019-03-31 14:32:06 +02:00
<!-- RSS -->
2021-08-20 13:21:20 +02:00
{{ range .AlternativeOutputFormats }}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink }}" title="{{ site.Title }}">
{{ end }}
2019-06-10 21:29:55 +02:00
<!-- Misc -->
2021-08-20 13:21:20 +02:00
{{ if hugo.IsProduction | eq site.Params.env "production" }}
{{ template "_internal/google_analytics_async.html" . }}
{{ template "_internal/google_news.html" . }}
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/schema.html" . }}
{{ template "_internal/twitter_cards.html" . }}
{{ end }}
2019-03-31 14:32:06 +02:00
</head>
2021-08-20 13:21:20 +02:00
<body class="not-ready" data-menu="{{ isset site.Menus `main` }}">
2019-03-31 14:32:06 +02:00
<header class="header">
2021-08-20 13:21:20 +02:00
{{ $tag := cond .IsHome "h1" "p" }}
{{ printf `
<%s class="logo">
<a class="site-name" href="%s">%s</a>
<a class="btn-theme"></a>
</%s>
` $tag ("" | absURL) site.Title $tag | safeHTML }}
<script>
const bodyClass = document.body.classList;
const schemeDark = window.matchMedia('(prefers-color-scheme: dark)');
const buttonDark = document.querySelector('.btn-theme');
const setDark = () => {
bodyClass.add('dark');
localStorage.setItem('dark', 'true');
};
const setLight = () => {
bodyClass.remove('dark');
localStorage.removeItem('dark');
};
if (schemeDark.matches || localStorage.getItem('dark')) setDark();
requestAnimationFrame(() => {
bodyClass.remove('not-ready');
});
schemeDark.addEventListener('change', event => {
event.matches ? setDark() : setLight();
});
buttonDark.addEventListener('click', () => {
bodyClass.contains('dark') ? setLight() : setDark();
});
</script>
{{ if site.Menus.main }}
<nav class="menu">
{{ range site.Menus.main }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
2019-08-19 22:12:49 +02:00
</nav>
2021-08-20 13:21:20 +02:00
{{ end }}
{{ if site.Params.twitter }}
<a class="social-icon twitter" href="https://twitter.com/{{ site.Params.twitter }}" target="_blank"></a>
{{ end }}
{{ if site.Params.github }}
<a class="social-icon github" href="https://github.com/{{ site.Params.github }}" target="_blank"></a>
{{ end }}
{{ if site.Params.instagram }}
<a class="social-icon instagram" href="https://www.instagram.com/{{ site.Params.instagram }}/" target="_blank"></a>
{{ end }}
2019-03-31 14:32:06 +02:00
</header>
<main class="main">