all repos — archie @ c6dbd5eadf1ebb4f026e8a68b62d2833d3206511

A minimal Hugo Theme

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	{{ with .OutputFormats.Get "rss" -}}
 20	{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
 21	{{ end -}}
 22
 23	{{- template "_internal/opengraph.html" . -}}
 24	{{- template "_internal/twitter_cards.html" . -}}
 25	{{ if and (isset .Site.Params "social") (.Site.Params.useCDN | default false) -}}
 26		<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
 27	{{- else if or (isset .Site.Params "social") (eq .Site.Params.mode "toggle") -}}
 28		<script src="{{ .Site.BaseURL }}js/feather.min.js"></script>
 29	{{ end }}
 30	{{ if .Site.Params.useCDN | default false -}}
 31        <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel="stylesheet">
 32        <link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel="stylesheet">
 33        <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
 34	{{- else -}}
 35	{{ $fontstyle := resources.Get "css/fonts.css" | fingerprint }}
 36        <link href="{{ $fontstyle.Permalink }}" rel="stylesheet">
 37	{{ end }}
 38
 39	{{ $style := resources.Get "css/main.css" | fingerprint }}
 40	<link rel="stylesheet" type="text/css" media="screen" href="{{ $style.Permalink }}" />
 41
 42	{{- if or (eq .Site.Params.mode "auto") (eq .Site.Params.mode "dark") (eq .Site.Params.mode "toggle") -}}
 43		{{ $darkstyle := resources.Get "css/dark.css" | fingerprint }}
 44		<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 }} />
 45	{{ end }}
 46
 47	<!-- Mathjax support -->
 48	{{ with .Site.Params.mathjax }}
 49		<script type="text/javascript"
 50		src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
 51		</script>
 52	
 53		<!-- inline Mathjax -->
 54		<script type="text/x-mathjax-config">
 55		MathJax.Hub.Config({
 56			tex2jax: {
 57				inlineMath: [['$','$'], ['\\(','\\)']],
 58				displayMath: [['$$','$$'], ['\[','\]']],
 59				processEscapes: true,
 60				processEnvironments: true,
 61				skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
 62				TeX: { equationNumbers: { autoNumber: "AMS" },
 63						 extensions: ["AMSmath.js", "AMSsymbols.js"] }
 64			}
 65		});
 66		</script>
 67	{{ end }}
 68
 69	<!-- KaTeX support -->
 70	{{ with .Site.Params.katex }}
 71		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css">
 72		<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.js"></script>
 73		<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
 74		
 75		<!-- inline KaTeX -->
 76		<script>
 77			document.addEventListener("DOMContentLoaded", function() {
 78					renderMathInElement(document.body, {
 79							delimiters: [
 80									{left: "$$", right: "$$", display: true},
 81									{left: "$", right: "$", display: false}
 82							]
 83					});
 84			});
 85			</script>
 86	{{ end }}
 87	
 88	<!-- Custom CSS style get applied last -->
 89	{{- if isset .Site.Params "customcss" }}
 90		{{ range .Site.Params.customCSS }}
 91		{{ $customstyle := resources.Get . | fingerprint }}
 92		<link rel="stylesheet" type="text/css" href="{{ $customstyle.Permalink }}">
 93		{{ end }}
 94	{{- end -}}
 95	{{- range .Site.Params.customJS }}
 96	{{- if or (hasPrefix . "http://") (hasPrefix . "https://") }}
 97	<script src="{{ . }}"></script>
 98	{{- else if (hasPrefix . "<script")}}
 99    {{ .| safeHTML }}
100	{{- else }}
101	<script src="{{ $.Site.BaseURL }}{{ . }}"></script>
102	{{- end }}
103	{{- end }}
104</head>