|
| 1 | +{{/* cSpell:ignore docsearch opengraph outputformat */ -}} |
| 2 | +<meta charset="utf-8"> |
| 3 | +<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 4 | + |
| 5 | +{{ $darkMode := partialCached "dark-mode-config.html" "dark-mode-global" -}} |
| 6 | +{{ if $darkMode.enable -}} |
| 7 | +{{/* Browser hints before CSS loads */ -}} |
| 8 | +<meta name="color-scheme" content="light dark"> |
| 9 | +<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff"> |
| 10 | +<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000000"> |
| 11 | + |
| 12 | +{{/* Styles to set canvas colors and avoid transitions */ -}} |
| 13 | +<style> |
| 14 | + {{/* Set system colors as default */ -}} |
| 15 | + html { background: Canvas; color: CanvasText; } |
| 16 | + {{/* Define reasonable dark defaults */ -}} |
| 17 | + @media (prefers-color-scheme: dark) { |
| 18 | + html { background: #0b0d12; color: #e6e6e6; } |
| 19 | + } |
| 20 | + {{/* Avoid transitions until theme CSS is loaded */ -}} |
| 21 | + html[data-theme-init] * { transition: none !important; } |
| 22 | +</style> |
| 23 | + |
| 24 | +{{/* Set theme attribute before CSS loads to prevent flash */ -}} |
| 25 | + |
| 26 | +<script> |
| 27 | + (function() { |
| 28 | + const themeKey = 'td-color-theme'; |
| 29 | + const storedTheme = localStorage.getItem(themeKey); |
| 30 | + let theme = storedTheme || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); |
| 31 | + |
| 32 | + if (theme === 'auto') { |
| 33 | + theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; |
| 34 | + } |
| 35 | + |
| 36 | + document.documentElement.setAttribute('data-bs-theme', theme); |
| 37 | + })(); |
| 38 | +</script> |
| 39 | +{{ end -}} |
| 40 | + |
| 41 | +{{ range .AlternativeOutputFormats -}} |
| 42 | +<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}"> |
| 43 | +{{ end -}} |
| 44 | + |
| 45 | +{{ $outputFormat := partial "outputformat.html" . -}} |
| 46 | +{{ if and hugo.IsProduction (ne $outputFormat "print") (ne .Site.Language.Lang "xx") -}} |
| 47 | +<meta name="robots" content="index, follow"> |
| 48 | +{{ else -}} |
| 49 | +<meta name="robots" content="noindex, nofollow"> |
| 50 | +{{ end -}} |
| 51 | + |
| 52 | +{{ partialCached "favicons.html" . }} |
| 53 | +<title> |
| 54 | + {{- if .IsHome -}} |
| 55 | + {{ .Site.Title -}} |
| 56 | + {{ else -}} |
| 57 | + {{ with .Title }}{{ . }} | {{ end -}} |
| 58 | + {{ .Site.Title -}} |
| 59 | + {{ end -}} |
| 60 | +</title> |
| 61 | +<meta name="description" content="{{ partial "page-description.html" . }}"> |
| 62 | +{{ partial "opengraph.html" . -}} |
| 63 | +{{ partial "schema.html" . -}} |
| 64 | +{{ partial "twitter_cards.html" . -}} |
| 65 | +{{ partialCached "head-css.html" . "head-css-cache-key" -}} |
| 66 | +<script |
| 67 | + src="https://code.jquery.com/jquery-3.7.1.min.js" |
| 68 | + integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" |
| 69 | + crossorigin="anonymous"></script> |
| 70 | + |
| 71 | +{{ if .Site.Params.baidu_site -}} |
| 72 | +<script> |
| 73 | + var _hmt = _hmt || []; |
| 74 | + (function() { |
| 75 | + var hm = document.createElement("script"); |
| 76 | + hm.src = "https://hm.baidu.com/hm.js?d039af8a06fb16b792d3886805815add"; |
| 77 | + var s = document.getElementsByTagName("script")[0]; |
| 78 | + s.parentNode.insertBefore(hm, s); |
| 79 | + })(); |
| 80 | +</script> |
| 81 | +{{ end -}} |
| 82 | + |
| 83 | +{{ if .Site.Params.offlineSearch -}} |
| 84 | +<script defer |
| 85 | + src="https://unpkg.com/lunr@2.3.9/lunr.min.js" |
| 86 | + integrity="sha384-203J0SNzyqHby3iU6hzvzltrWi/M41wOP5Gu+BiJMz5nwKykbkUx8Kp7iti0Lpli" |
| 87 | + crossorigin="anonymous"></script> |
| 88 | +{{ end -}} |
| 89 | + |
| 90 | +{{ if .Site.Params.prism_syntax_highlighting -}} |
| 91 | +<link rel="stylesheet" href="{{ "css/prism.css" | relURL }}"/> |
| 92 | +{{ end -}} |
| 93 | + |
| 94 | +{{ template "algolia/head" . -}} |
| 95 | + |
| 96 | +{{ partial "hooks/head-end.html" . -}} |
| 97 | + |
| 98 | +{{/* To comply with GDPR, cookie consent scripts places in head-end must execute before Google Analytics is enabled */ -}} |
| 99 | +{{ if hugo.IsProduction -}} |
| 100 | + {{ partial "google_analytics.html" . -}} |
| 101 | +{{ end -}} |
| 102 | + |
| 103 | +{{ define "algolia/head" -}} |
| 104 | + |
| 105 | +{{ if and .Site.Params.search (isset .Site.Params.search "algolia") -}} |
| 106 | +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3.8.2" |
| 107 | + integrity="sha512-l7pkV1dOURFyHCeH8I4fK9lCkQKuqhlsTCqRl3zktifDlB8oTUJ+mJPgYkK9kHpUut8j1iPquTv32t6hvTPv3g==" |
| 108 | + crossorigin="anonymous" /> |
| 109 | +{{ end -}} |
| 110 | + |
| 111 | +{{ if ne .Site.Params.algolia_docsearch nil -}} |
| 112 | +{{ warnf `Config 'params.algolia_docsearch' is deprecated: use 'params.search.algolia' |
| 113 | + For details, see https://www.docsy.dev/docs/content/search/#algolia-docsearch.` -}} |
| 114 | +{{ end -}} |
| 115 | + |
| 116 | +{{ end -}} |
0 commit comments