layouts/partials/header.html (view raw)
1<head>
2 <meta charset="utf-8" />
3 <meta http-equiv="X-UA-Compatible" content="IE=edge">
4 {{- $title := ( .Title ) -}}
5 {{- $siteTitle := ( .Site.Title ) -}}
6 {{- if or (.IsHome) (eq .Title "Home") -}}
7 <title>{{ $siteTitle }}</title>
8 {{- else -}}
9 <title>{{ $siteTitle }} - {{ $title }}</title>
10 {{- end -}}
11
12 {{- if isset .Site.Params "favicon" -}}
13 <link rel="icon" type="image/png" href={{ .Site.Params.favicon }} />
14 {{- end -}}
15
16 <meta name="viewport" content="width=device-width, initial-scale=1">
17 <meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
18 <meta property="og:image" content="{{ .Site.Params.og_image }}"/>
19 {{ if and (not .Draft) (.Params.Redirect) }}<meta http-equiv="Refresh" content="0; url='{{ .Params.redirect }}'" />{{ end }}
20 {{ with .OutputFormats.Get "rss" -}}
21 {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
22 {{ end -}}
23
24 {{- template "_internal/opengraph.html" . -}}
25 {{- template "_internal/twitter_cards.html" . -}}
26 {{ if and (isset .Site.Params "social") (.Site.Params.useCDN | default false) -}}
27 <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
28 {{- else if or (isset .Site.Params "social") (eq .Site.Params.mode "toggle") -}}
29 <script src="{{ .Site.BaseURL }}js/feather.min.js"></script>
30 {{ end }}
31 {{ if .Site.Params.useCDN | default false -}}
32 <link href="https://fonts.bunny.net/css2?family=Fira+Sans&display=swap2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel="stylesheet">
33 <link href="https://fonts.bunny.net/css2?family=Fira+Sans&display=swap" rel="stylesheet">
34 <link href="https://fonts.bunny.net/css?family=Roboto+Mono" rel="stylesheet">
35 {{- else -}}
36 {{ $fontstyle := resources.Get "css/fonts.css" | fingerprint }}
37 <link href="{{ $fontstyle.Permalink }}" rel="stylesheet">
38 {{ end }}
39
40 {{ $style := resources.Get "css/main.css" | fingerprint }}
41 <link rel="stylesheet" type="text/css" media="screen" href="{{ $style.Permalink }}" />
42
43 {{- if or (eq .Site.Params.mode "auto") (eq .Site.Params.mode "dark") (eq .Site.Params.mode "toggle") -}}
44 {{ $darkstyle := resources.Get "css/dark.css" | fingerprint }}
45 <link id="darkModeStyle" rel="stylesheet" type="text/css" href="{{ $darkstyle.Permalink }}" {{ if eq .Site.Params.mode "auto" }}media="(prefers-color-scheme: dark)"{{ end }} {{ if eq .Site.Params.mode "toggle" }}disabled{{ end }} />
46 {{ end }}
47
48 <!-- Mathjax support -->
49 {{ with .Site.Params.mathjax }}
50 <script type="text/javascript"
51 src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
52 </script>
53
54 <!-- inline Mathjax -->
55 <script type="text/x-mathjax-config">
56 MathJax.Hub.Config({
57 tex2jax: {
58 inlineMath: [['$','$'], ['\\(','\\)']],
59 displayMath: [['$$','$$'], ['\[','\]']],
60 processEscapes: true,
61 processEnvironments: true,
62 skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
63 TeX: { equationNumbers: { autoNumber: "AMS" },
64 extensions: ["AMSmath.js", "AMSsymbols.js"] }
65 }
66 });
67 </script>
68 {{ end }}
69
70 <!-- KaTeX support -->
71 {{ with .Site.Params.katex }}
72 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css">
73 <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.js"></script>
74 <script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
75
76 <!-- inline KaTeX -->
77 <script>
78 document.addEventListener("DOMContentLoaded", function() {
79 renderMathInElement(document.body, {
80 delimiters: [
81 {left: "$$", right: "$$", display: true},
82 {left: "$", right: "$", display: false}
83 ]
84 });
85 });
86 </script>
87 {{ end }}
88
89 <!-- Custom CSS style get applied last -->
90 {{- if isset .Site.Params "customcss" }}
91 {{ range .Site.Params.customCSS }}
92 {{ $customstyle := resources.Get . | fingerprint }}
93 <link rel="stylesheet" type="text/css" href="{{ $customstyle.Permalink }}">
94 {{ end }}
95 {{- end -}}
96 {{- range .Site.Params.customJS }}
97 {{- if or (hasPrefix . "http://") (hasPrefix . "https://") }}
98 <script src="{{ . }}"></script>
99 {{- else if (hasPrefix . "<script")}}
100 {{ .| safeHTML }}
101 {{- else }}
102 <script src="{{ $.Site.BaseURL }}{{ . }}"></script>
103 {{- end }}
104 {{- end }}
105</head>