head.html (8496B)
1 <meta charset="utf-8"> 2 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 3 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 4 {{- if hugo.IsProduction | or (eq site.Params.env "production") | and (ne .Params.robotsNoIndex true) }} 5 <meta name="robots" content="index, follow"> 6 {{- else }} 7 <meta name="robots" content="noindex, nofollow"> 8 {{- end }} 9 10 {{- /* Title */}} 11 <title>{{ if .IsHome }}{{ else }}{{ if .Title }}{{ .Title }} | {{ end }}{{ end }}{{ site.Title }}</title> 12 13 {{- /* Meta */}} 14 {{- if .IsHome }} 15 {{ with site.Params.keywords -}}<meta name="keywords" content="{{- range $i, $e := . }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}">{{ end }} 16 {{- else }} 17 <meta name="keywords" content="{{ if .Params.keywords -}} 18 {{- range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{- else }} 19 {{- range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} {{- end -}}"> 20 {{- end }} 21 <meta name="description" content="{{- with .Description }}{{ . }}{{- else }}{{- if or .IsPage .IsSection}} 22 {{- .Summary | default (printf "%s - %s" .Title site.Title) }}{{- else }} 23 {{- with site.Params.description }}{{ . }}{{- end }}{{- end }}{{- end -}}"> 24 <meta name="author" content="{{ (partial "author.html" . ) }}"> 25 <link rel="canonical" href="{{ if .Params.canonicalURL -}} {{ trim .Params.canonicalURL " " }} {{- else -}} {{ .Permalink }} {{- end }}"> 26 {{- if site.Params.analytics.google.SiteVerificationTag }} 27 <meta name="google-site-verification" content="{{ site.Params.analytics.google.SiteVerificationTag }}"> 28 {{- end }} 29 {{- if site.Params.analytics.yandex.SiteVerificationTag }} 30 <meta name="yandex-verification" content="{{ site.Params.analytics.yandex.SiteVerificationTag }}"> 31 {{- end }} 32 {{- if site.Params.analytics.bing.SiteVerificationTag }} 33 <meta name="msvalidate.01" content="{{ site.Params.analytics.bing.SiteVerificationTag }}"> 34 {{- end }} 35 {{- if site.Params.analytics.naver.SiteVerificationTag }} 36 <meta name="naver-site-verification" content="{{ site.Params.analytics.naver.SiteVerificationTag }}"> 37 {{- end }} 38 39 {{- /* Styles */}} 40 41 {{- /* includes */}} 42 {{- $includes := slice }} 43 {{- $includes = $includes | append (" " | resources.FromString "assets/css/includes-blank.css")}} 44 45 {{- $includes_all := $includes | resources.Concat "assets/css/includes.css" }} 46 47 {{- $theme_vars := (resources.Get "css/core/theme-vars.css") }} 48 {{- $reset := (resources.Get "css/core/reset.css") }} 49 {{- $media := (resources.Get "css/core/zmedia.css") }} 50 {{- $license_css := (resources.Get "css/core/license.css") }} 51 {{- $common := (resources.Match "css/common/*.css") | resources.Concat "assets/css/common.css" }} 52 53 {{- /* markup.highlight.noClasses should be set to `false` */}} 54 {{- $chroma_styles := (resources.Get "css/includes/chroma-styles.css") }} 55 {{- $chroma_mod := (resources.Get "css/includes/chroma-mod.css") }} 56 57 {{- /* order is important */}} 58 {{- $core := (slice $theme_vars $reset $common $chroma_styles $chroma_mod $includes_all $media) | resources.Concat "assets/css/core.css" | resources.Minify }} 59 {{- $extended := (resources.Match "css/extended/*.css") | resources.Concat "assets/css/extended.css" | resources.Minify }} 60 61 {{- /* bundle all required css */}} 62 {{- /* Add extended css after theme style */ -}} 63 {{- $stylesheet := (slice $license_css $core $extended) | resources.Concat "assets/css/stylesheet.css" }} 64 65 {{- if not site.Params.assets.disableFingerprinting }} 66 {{- $stylesheet := $stylesheet | fingerprint }} 67 <link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" integrity="{{ $stylesheet.Data.Integrity }}" rel="preload stylesheet" as="style"> 68 {{- else }} 69 <link crossorigin="anonymous" href="{{ $stylesheet.RelPermalink }}" rel="preload stylesheet" as="style"> 70 {{- end }} 71 72 {{- /* Search */}} 73 {{- if (eq .Layout `search`) -}} 74 <link crossorigin="anonymous" rel="preload" as="fetch" href="../index.json"> 75 {{- $fastsearch := resources.Get "js/fastsearch.js" | js.Build (dict "params" (dict "fuseOpts" site.Params.fuseOpts)) | resources.Minify }} 76 {{- $fusejs := resources.Get "js/fuse.basic.min.js" }} 77 {{- $license_js := resources.Get "js/license.js" }} 78 {{- if not site.Params.assets.disableFingerprinting }} 79 {{- $search := (slice $fusejs $license_js $fastsearch ) | resources.Concat "assets/js/search.js" | fingerprint }} 80 <script defer crossorigin="anonymous" src="{{ $search.RelPermalink }}" integrity="{{ $search.Data.Integrity }}"></script> 81 {{- else }} 82 {{- $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" }} 83 <script defer crossorigin="anonymous" src="{{ $search.RelPermalink }}"></script> 84 {{- end }} 85 {{- end -}} 86 87 {{- /* Favicons */}} 88 <link rel="icon" href="{{ site.Params.assets.favicon | default "favicon.ico" | absURL }}"> 89 <link rel="icon" type="image/png" sizes="16x16" href="{{ site.Params.assets.favicon16x16 | default "favicon-16x16.png" | absURL }}"> 90 <link rel="icon" type="image/png" sizes="32x32" href="{{ site.Params.assets.favicon32x32 | default "favicon-32x32.png" | absURL }}"> 91 <link rel="apple-touch-icon" href="{{ site.Params.assets.apple_touch_icon | default "apple-touch-icon.png" | absURL }}"> 92 <link rel="mask-icon" href="{{ site.Params.assets.safari_pinned_tab | default "safari-pinned-tab.svg" | absURL }}"> 93 <meta name="theme-color" content="{{ site.Params.assets.theme_color | default "#2e2e33" }}"> 94 <meta name="msapplication-TileColor" content="{{ site.Params.assets.msapplication_TileColor | default "#2e2e33" }}"> 95 96 {{- /* RSS */}} 97 {{ range .AlternativeOutputFormats -}} 98 <link rel="{{ .Rel }}" type="{{ .MediaType.Type | html }}" href="{{ .Permalink | safeURL }}" title="{{ .Name }}"> 99 {{ end -}} 100 {{- range .AllTranslations -}} 101 <link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}"> 102 {{ end -}} 103 104 <noscript> 105 <style> 106 #theme-toggle, 107 .top-link { 108 display: none; 109 } 110 111 </style> 112 {{- if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark")) }} 113 <style> 114 @media (prefers-color-scheme: dark) { 115 :root { 116 --theme: rgb(29, 30, 32); 117 --entry: rgb(46, 46, 51); 118 --primary: rgb(218, 218, 219); 119 --secondary: rgb(155, 156, 157); 120 --tertiary: rgb(65, 66, 68); 121 --content: rgb(196, 196, 197); 122 --code-block-bg: rgb(46, 46, 51); 123 --code-bg: rgb(55, 56, 62); 124 --border: rgb(51, 51, 51); 125 color-scheme: dark; 126 } 127 128 .list { 129 background: var(--theme); 130 } 131 132 .toc { 133 background: var(--entry); 134 } 135 } 136 137 </style> 138 {{- end }} 139 </noscript> 140 141 {{- /* theme-toggle is enabled */}} 142 {{- if (not site.Params.disableThemeToggle) }} 143 {{- /* theme is light */}} 144 {{- if (eq site.Params.defaultTheme "light") }} 145 <script> 146 if (localStorage.getItem("pref-theme") === "dark") { 147 document.querySelector("html").dataset.theme = 'dark'; 148 } 149 150 </script> 151 {{- /* theme is dark */}} 152 {{- else if (eq site.Params.defaultTheme "dark") }} 153 <script> 154 if (localStorage.getItem("pref-theme") === "light") { 155 document.querySelector("html").dataset.theme = 'light'; 156 } 157 158 </script> 159 {{- else }} 160 {{- /* theme is auto */}} 161 <script> 162 if (localStorage.getItem("pref-theme") === "dark") { 163 document.querySelector("html").dataset.theme = 'dark'; 164 } else if (localStorage.getItem("pref-theme") === "light") { 165 document.querySelector("html").dataset.theme = 'light'; 166 } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { 167 document.querySelector("html").dataset.theme = 'dark'; 168 } else { 169 document.querySelector("html").dataset.theme = 'light'; 170 } 171 172 </script> 173 {{- end }} 174 {{- /* theme-toggle is disabled and theme is auto */}} 175 {{- else if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark"))}} 176 <script> 177 if (window.matchMedia('(prefers-color-scheme: dark)').matches) { 178 document.querySelector("html").dataset.theme = 'dark'; 179 } else { 180 document.querySelector("html").dataset.theme = 'light'; 181 } 182 183 </script> 184 {{- end }} 185 186 {{- partial "extend_head.html" . -}} 187 188 {{- /* Misc */}} 189 {{- if hugo.IsProduction | or (eq site.Params.env "production") }} 190 {{- partial "google_analytics.html" . }} 191 {{- partial "templates/opengraph.html" . }} 192 {{- partial "templates/twitter_cards.html" . }} 193 {{- partial "templates/schema_json.html" . }} 194 {{- end -}}