Add post: 暗黑能天使
This commit is contained in:
186
layouts/partials/head.html
Normal file
186
layouts/partials/head.html
Normal file
@@ -0,0 +1,186 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{{ define "partials/get-title" }}
|
||||
{{ $separator := .Site.Params.titleSeparator | default "|" }}
|
||||
{{ $primarySep := $separator }}
|
||||
{{ $secondarySep := $separator }}
|
||||
{{ if reflect.IsSlice $separator }}
|
||||
{{ $primarySep = index $separator 0 }}
|
||||
{{ $secondarySep = index $separator 1 | default (index $separator 0) }}
|
||||
{{ end }}
|
||||
{{ $title := .Site.Title }}
|
||||
{{/* Generate prefix */}}
|
||||
{{ $prefix := "" }}
|
||||
{{ if .Params.Title }}
|
||||
{{ $prefix = .Params.Title }}
|
||||
{{/* Deprecation warning(v1.0.0) starts */}}
|
||||
{{ $layout := partial "utils/hyphenate" (.Layout | default .Type) }}
|
||||
{{/* Deprecation warning(v1.0.0) ends */}}
|
||||
{{ if and (eq .Type "docs") (ne $layout "doc-list") }}
|
||||
{{ $docTitle := "" }}
|
||||
{{ $bundles := partial "utils/get-bundles" . }}
|
||||
{{ range $bundles.Reverse }}
|
||||
{{ $version := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?" (path.Base .Permalink) }}
|
||||
{{/* Deprecation warning(v1.0.0) starts */}}
|
||||
{{ $parentLayout := partial "utils/hyphenate" (.Parent.Layout | default .Parent.Type) }}
|
||||
{{ $layout := partial "utils/hyphenate" (.Layout | default .Type) }}
|
||||
{{/* Deprecation warning(v1.0.0) ends */}}
|
||||
{{ if and (eq $parentLayout "doc-list") (ne $layout "doc-list") }}
|
||||
{{ $docTitle = .Title }}
|
||||
{{ else if $version }}
|
||||
{{ $docTitle = .Title }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{/* Doc title */}}
|
||||
{{ $version := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?" (path.Base .Permalink) }}
|
||||
{{/* Deprecation warning(v1.0.0) starts */}}
|
||||
{{ $parentLayout := partial "utils/hyphenate" (.Parent.Layout | default .Parent.Type) }}
|
||||
{{/* Deprecation warning(v1.0.0) ends */}}
|
||||
{{ if or (eq $parentLayout "doc-list") $version }}
|
||||
{{ $prefix = $docTitle }}
|
||||
{{ else }}
|
||||
{{ $prefix = print $prefix " " $secondarySep " " $docTitle }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{/* Add prefix */}}
|
||||
{{ with $prefix }}
|
||||
{{ $title = print . " " $primarySep " " $title }}
|
||||
{{ end }}
|
||||
{{ return $title }}
|
||||
{{ end }}
|
||||
<title>{{ partial "get-title" . }}</title>
|
||||
|
||||
<meta name="generator" content="Hugo Eureka {{ .Site.Data.eureka.version }}" />
|
||||
|
||||
{{- $eurekaCSS := resources.Get "css/eureka.css" | postCSS (dict "config" "./assets/css/postcss.config.js" "inlineImports" true) | resources.ExecuteAsTemplate "css/eureka.css" . | minify | fingerprint "sha384" }}
|
||||
<link rel="stylesheet" href="{{ $eurekaCSS.Permalink }}">
|
||||
|
||||
{{- $eurekaJS := resources.Get "js/eureka.js" | resources.ExecuteAsTemplate "js/eureka.js" . | minify | fingerprint "sha384" }}
|
||||
<script defer src="{{ $eurekaJS.Permalink }}"></script>
|
||||
|
||||
{{ $googleFonts := "" }}
|
||||
{{ range $index, $value := partial "utils/get-style-fonts" (dict "context" . "param" "googleFonts") }}
|
||||
{{ with $value }}
|
||||
{{ $googleFonts = print $googleFonts "family=" . "&" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ with $googleFonts }}
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="preload"
|
||||
href="{{ printf "https://fonts.googleapis.com/css2?%sdisplay=swap" . }}"
|
||||
as="style" onload="this.onload=null;this.rel='stylesheet'">
|
||||
{{ end }}
|
||||
|
||||
{{- $assets := .Site.Data.assets }}
|
||||
|
||||
{{/* highlight */}}
|
||||
{{- if eq .Site.Params.highlight.handler "chroma" }}
|
||||
{{- $highlightCSS := resources.Get "css/syntax.css" | minify | fingerprint "sha384" }}
|
||||
<link rel="stylesheet" href="{{ $highlightCSS.Permalink }}" media="print" onload="this.media='all';this.onload=null">
|
||||
{{- else if eq .Site.Params.highlight.handler "highlightjs" }}
|
||||
{{- $highlightjsStyle := .Site.Params.highlight.highlightjs.style | default "base16/solarized-light" }}
|
||||
<link rel="stylesheet" href="{{ printf $assets.highlightjs.css.url $assets.highlightjs.version $highlightjsStyle }}"
|
||||
{{ with $assets.highlightjs.css.sri }} integrity="{{ . }}" {{ end }} media="print"
|
||||
onload="this.media='all';this.onload=null" crossorigin>
|
||||
<script defer src="{{ printf $assets.highlightjs.js.url $assets.highlightjs.version }}"
|
||||
{{ with $assets.highlightjs.js.sri }} integrity="{{ . }}" {{ end }} crossorigin></script>
|
||||
{{- range .Site.Params.highlight.highlightjs.languages }}
|
||||
<script defer src="{{ printf $assets.highlightjs.languages.url $assets.highlightjs.version . }}"
|
||||
{{ with $assets.highlightjs.languages.sri }} integrity="{{ . }}" {{ end }} crossorigin></script>
|
||||
{{- end }}
|
||||
{{- $highlightjsCSS := resources.Get "css/highlightjs.css" | minify | fingerprint "sha384" }}
|
||||
<link rel="stylesheet" href="{{ $highlightjsCSS.Permalink }}" media="print" onload="this.media='all';this.onload=null">
|
||||
{{- end }}
|
||||
|
||||
{{ $fontawesomeJS := resources.Get "js/fontawesome.js" | resources.ExecuteAsTemplate "js/fontawesome.js" . | js.Build (dict "minify" true) | minify | fingerprint "sha384" }}
|
||||
<script defer type="text/javascript" src="{{ $fontawesomeJS.Permalink }}"></script>
|
||||
|
||||
|
||||
{{- $enableMath := false }}
|
||||
{{- if .Site.Params.math.handler }}
|
||||
{{- $bundles := partial "utils/get-bundles" . }}
|
||||
{{- $enableMath = true }}
|
||||
{{- range $bundles.Reverse }}
|
||||
{{- if and (ne .Params.enableMath nil) (ne .Params.enableMath "") }}
|
||||
{{- $enableMath = .Params.enableMath }}
|
||||
{{/* Deprecation warning(v1.0.0) starts */}}
|
||||
{{- else if and (ne .Params.math nil) (ne .Params.math "") }}
|
||||
{{ warnf "Param 'math' in %q is deprecated and will be removed in Eureka v1.0.0. Please use 'enableMath' instead." .File.Path }}
|
||||
{{- $enableMath = .Params.math }}
|
||||
{{/* Deprecation warning(v1.0.0) ends */}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/* KaTeX */}}
|
||||
{{- if and (eq .Site.Params.math.handler "katex") $enableMath }}
|
||||
<link rel="stylesheet" href="{{ printf $assets.katex.css.url $assets.katex.version }}"
|
||||
{{ with $assets.katex.css.sri }} integrity="{{ . }}" {{ end }} media="print"
|
||||
onload="this.media='all';this.onload=null" crossorigin>
|
||||
<script defer src="{{ printf $assets.katex.js.url $assets.katex.version }}" {{ with $assets.katex.js.sri }}
|
||||
integrity="{{ . }}" {{ end }} crossorigin></script>
|
||||
<script defer src="{{ printf $assets.katex.autoRender.url $assets.katex.version }}"
|
||||
{{ with $assets.katex.autoRender.sri }} integrity="{{ . }}" {{ end }} crossorigin></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
renderMathInElement(document.body, {
|
||||
delimiters: [
|
||||
{ left: "$$", right: "$$", display: true },
|
||||
{ left: "$", right: "$", display: false },
|
||||
{ left: "\\(", right: "\\)", display: false },
|
||||
{ left: "\\[", right: "\\]", display: true }
|
||||
],
|
||||
{{- partial "utils/get-js-configs" .Site.Params.math.katex | safeJS }}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{- end }}
|
||||
|
||||
{{/* Mermaid */}}
|
||||
{{- if eq .Site.Params.diagram.handler "mermaid" }}
|
||||
<script defer src="{{ printf $assets.mermaid.js.url $assets.mermaid.version }}" {{ with $assets.mermaid.js.sri }}
|
||||
integrity="{{ . }}" {{ end }} crossorigin></script>
|
||||
{{- with .Site.Params.diagram.mermaid }}
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
mermaid.initialize({
|
||||
{{- partial "utils/get-js-configs" . | safeJS }}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if and .Site.GoogleAnalytics hugo.IsProduction }}
|
||||
<link rel="preconnect" href="https://www.google-analytics.com" crossorigin>
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.GoogleAnalytics }}"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
gtag('config', '{{ .Site.GoogleAnalytics }}');
|
||||
</script>
|
||||
{{- end }}
|
||||
|
||||
{{ partial "custom-head" . }}
|
||||
|
||||
{{- with .Site.Params.icon }}
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{{ (partial "get-icon" (dict "icon" . "size" 32)).Permalink }}">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ (partial "get-icon" (dict "icon" . "size" 180)).Permalink }}">
|
||||
{{- end }}
|
||||
|
||||
{{ define "partials/get-icon" }}
|
||||
{{ $icon := resources.GetMatch .icon }}
|
||||
{{ $iconResized := $icon.Fill (printf "%sx%s Center" (string .size) (string .size)) }}
|
||||
{{ return $iconResized }}
|
||||
{{ end }}
|
||||
|
||||
{{- partial "components/schema" . }}
|
||||
{{- partial "components/opengraph" . }}
|
||||
{{- range .AlternativeOutputFormats }}
|
||||
{{- printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user