favicon html

This commit is contained in:
archer 2023-09-04 18:16:29 +08:00
parent ae88d79d6f
commit 5d596bd3d5
No known key found for this signature in database
GPG Key ID: 569A5660D2379E28
2 changed files with 93 additions and 73 deletions

View File

@ -0,0 +1,18 @@
{{ if os.FileExists "static/favicon.ico" -}}
<link rel="icon" href="{{ " favicon.ico" | absURL }}" sizes="any">
{{ end -}}
{{ if os.FileExists "static/favicon.svg" -}}
<link rel="icon" type="image/svg+xml" href="{{ " favicon.svg" | absURL }}">
{{ end -}}
{{ if os.FileExists "static/apple-touch-icon.png" -}}
<link rel="apple-touch-icon" sizes="180x180" href="{{ " apple-touch-icon.png" | absURL }}">
{{ end -}}
{{ if os.FileExists "static/favicon-32x32.png" -}}
<link rel="icon" type="image/png" sizes="32x32" href="{{ " favicon-32x32.png" | absURL }}">
{{ end -}}
{{ if os.FileExists "static/favicon-16x16.png" -}}
<link rel="icon" type="image/png" sizes="16x16" href="{{ " favicon-16x16.png" | absURL }}">
{{ end -}}
{{ if os.FileExists "static/site.webmanifest" -}}
<link rel="manifest" crossorigin="use-credentials" href="{{ " site.webmanifest" | absURL }}">
{{ end -}}

View File

@ -1,74 +1,76 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title> <title>
{{- $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }} {{- $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }} {{- if eq $url "/" }} {{-
{{- if eq $url "/" }} .Site.Title }} {{- else }} {{- if .Params.heading }} {{ .Params.heading }} {{ else }} {{- if eq
{{- .Site.Title }} .Title .Site.Title }} {{- .Title }} {{- else }} {{ .Site.Params.docs.Title | default
{{- else }} (.Site.Title) }} | {{ .Title }} {{- end }} {{- end }} {{- end -}}
{{- if .Params.heading }} </title>
{{ .Params.heading }} {{- if not hugo.IsProduction }}
{{ else }} <meta name="robots" content="noindex" />
{{- if eq .Title .Site.Title }} {{- end }}
{{- .Title }} <meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{- else }} <meta name="description" content="A Modern Documentation Theme for Hugo" />
{{ .Site.Params.docs.Title | default (.Site.Title) }} | {{ .Title }} <meta name="keywords" content="Documentation, Hugo, Hugo Theme, Bootstrap" />
{{- end }} <meta name="author" content="Colin Wilson - Lotus Labs" />
{{- end }} <meta name="email" content="support@aigis.uk" />
{{- end -}} <meta name="website" content="https://lotusdocs.dev" />
</title> <meta name="Version" content="v0.1.0" />
{{- if not hugo.IsProduction }} <!-- favicon -->
<meta name="robots" content="noindex"> {{ block "favicon" . }}{{ partialCached (printf "%s/%s" ($.Scratch.Get "pathName")
{{- end }} "head/favicon.html") . }}{{ end }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Dark Mode -->
<meta name="description" content="A Modern Documentation Theme for Hugo" /> {{ if eq .Site.Params.docs.darkMode true -}} {{ $darkModeInit := resources.Get (printf "/%s/%s"
<meta name="keywords" content="Documentation, Hugo, Hugo Theme, Bootstrap" /> ($.Scratch.Get "pathName") "js/darkmode-init.js") | js.Build | minify -}}
<meta name="author" content="Colin Wilson - Lotus Labs" /> <script>
<meta name="email" content="support@aigis.uk" /> {
<meta name="website" content="https://lotusdocs.dev" /> {
<meta name="Version" content="v0.1.0" /> $darkModeInit.Content | safeJS;
<!-- favicon --> }
{{ block "favicon" . }}{{ partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "head/favicon.html") . }}{{ end }} }
<!-- Dark Mode --> </script>
{{ if eq .Site.Params.docs.darkMode true -}} {{ end -}}
{{ $darkModeInit := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "js/darkmode-init.js") | js.Build | minify -}} <!-- FlexSearch -->
<script>{{ $darkModeInit.Content | safeJS }}</script> {{ if or (not (isset .Site.Params.flexsearch "enabled")) (eq .Site.Params.flexsearch.enabled true)
{{ end -}} -}} {{ if and (.Site.Params.docsearch.appID) (.Site.Params.docsearch.apiKey) -}} {{ else }} {{
<!-- FlexSearch --> $flexSearch := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName")
{{ if or (not (isset .Site.Params.flexsearch "enabled")) (eq .Site.Params.flexsearch.enabled true) -}} "js/flexsearch.bundle.js") }} {{- if not .Site.IsServer }} {{ $flexSearch := $flexSearch | minify
{{ if and (.Site.Params.docsearch.appID) (.Site.Params.docsearch.apiKey) -}} | fingerprint "sha384" }}
{{ else }} <script
{{ $flexSearch := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "js/flexsearch.bundle.js") }} type="text/javascript"
{{- if not .Site.IsServer }} src="{{ $flexSearch.Permalink }}"
{{ $flexSearch := $flexSearch | minify | fingerprint "sha384" }} integrity="{{ $flexSearch.Data.Integrity }}"
<script type="text/javascript" src="{{ $flexSearch.Permalink }}" integrity="{{ $flexSearch.Data.Integrity }}" crossorigin="anonymous"></script> crossorigin="anonymous"
{{ else }} ></script>
<script type="text/javascript" src="{{ $flexSearch.Permalink }}"></script> {{ else }}
{{ end }} <script type="text/javascript" src="{{ $flexSearch.Permalink }}"></script>
{{ end }} {{ end }} {{ end }} {{ end }}
{{ end }} <!-- Google Fonts -->
<!-- Google Fonts --> {{- partialCached "google-fonts" . }}
{{- partialCached "google-fonts" . }} <!-- Custom CSS -->
<!-- Custom CSS --> {{- $options := dict "enableSourceMap" true }} {{- if hugo.IsProduction}} {{- $options := dict
{{- $options := dict "enableSourceMap" true }} "enableSourceMap" false "outputStyle" "compressed" }} {{- end }} {{- $style := resources.Get
{{- if hugo.IsProduction}} (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") }} {{- $style = $style |
{{- $options := dict "enableSourceMap" false "outputStyle" "compressed" }} resources.ExecuteAsTemplate (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") . |
{{- end }} resources.ToCSS $options }} {{- if hugo.IsProduction }} {{- $style = $style | minify | fingerprint
{{- $style := resources.Get (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") }} "sha384" }} {{- end -}}
{{- $style = $style | resources.ExecuteAsTemplate (printf "/%s/%s" ($.Scratch.Get "pathName") "scss/style.scss") . | resources.ToCSS $options }} <link
{{- if hugo.IsProduction }} rel="stylesheet"
{{- $style = $style | minify | fingerprint "sha384" }} href="{{ $style.RelPermalink }}"
{{- end -}} {{
<link rel="stylesheet" href="{{ $style.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $style.Data.Integrity }}"{{ end -}} crossorigin="anonymous"> if
<!-- Plausible Analytics Config --> hugo.IsProduction
{{- if not .Site.IsServer }} }}integrity="{{ $style.Data.Integrity }}"
{{ if and (.Site.Params.plausible.scriptURL | default "https://plausible.io") (.Site.Params.plausible.dataDomain) -}} {{
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "head/plausible") . }} end
{{- end -}} -}}
{{- end -}} crossorigin="anonymous"
<!-- Google Analytics v4 Config --> />
{{- if not .Site.IsServer }} <!-- Plausible Analytics Config -->
{{- if .Site.GoogleAnalytics }} {{- if not .Site.IsServer }} {{ if and (.Site.Params.plausible.scriptURL | default
{{- template "_internal/google_analytics.html" . -}} "https://plausible.io") (.Site.Params.plausible.dataDomain) -}} {{- partialCached (printf "%s/%s"
{{- end -}} ($.Scratch.Get "pathName") "head/plausible") . }} {{- end -}} {{- end -}}
{{- end -}} <!-- Google Analytics v4 Config -->
{{- if not .Site.IsServer }} {{- if .Site.GoogleAnalytics }} {{- template
"_internal/google_analytics.html" . -}} {{- end -}} {{- end -}}
</head> </head>