diff --git a/hugo.yaml b/hugo.yaml index 4ea538b..7633f95 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -82,6 +82,7 @@ params: displayCopyright: true displayPoweredBy: false width: normal + icp: "粤ICP备2026061516号" # 日期 displayUpdatedDate: false @@ -94,6 +95,7 @@ params: flexsearch: index: content tokenize: forward + base: "https://unpkg.com/flexsearch@0.7.43/dist" # 博客 blog: @@ -138,7 +140,9 @@ params: # Mermaid 流程图(本地加载,避免 CDN 连接问题) mermaid: - base: "https://cdn.jsdelivr.net/npm/mermaid@11.15.0/dist" + base: "https://unpkg.com/mermaid@11.4.1/dist" + lightTheme: neutral + darkTheme: dark # Open Graph / SEO 增强 opengraph: diff --git a/layouts/_partials/custom/head-end.html b/layouts/_partials/custom/head-end.html index bfe996f..462ff11 100644 --- a/layouts/_partials/custom/head-end.html +++ b/layouts/_partials/custom/head-end.html @@ -9,56 +9,3 @@ }); }); - - - diff --git a/layouts/_partials/footer.html b/layouts/_partials/footer.html new file mode 100644 index 0000000..40ae2d2 --- /dev/null +++ b/layouts/_partials/footer.html @@ -0,0 +1,42 @@ +{{- $enableFooterSwitches := .Store.Get "enableFooterSwitches" | default false -}} +{{- $displayThemeToggle := site.Params.theme.displayToggle | default true -}} +{{- $footerSwitchesVisible := and $enableFooterSwitches (or hugo.IsMultilingual $displayThemeToggle) -}} +{{- $copyrightSectionVisible := or (.Site.Params.footer.displayPoweredBy | default true) .Site.Params.footer.displayCopyright -}} + +{{- $copyright := (T "copyright") | default "© 2024 Hextra." -}} +{{- $poweredBy := (T "poweredBy") | default "Powered by Hextra" -}} + + + +{{- define "theme-credit" -}} + + + {{- . | markdownify -}} + {{- if strings.Contains . "Hextra" -}} + {{- partial "utils/icon.html" (dict "name" "hextra" "attributes" `height=1em class="hx:inline-block hx:ltr:ml-1 hx:rtl:mr-1 hx:align-[-2.5px]"`) -}} + {{- end -}} + + +{{- end -}} diff --git a/layouts/_partials/scripts/mermaid.html b/layouts/_partials/scripts/mermaid.html new file mode 100644 index 0000000..fe650e2 --- /dev/null +++ b/layouts/_partials/scripts/mermaid.html @@ -0,0 +1,113 @@ +{{- /* Mermaid */ -}} + +{{- $mermaidBase := "" -}} +{{- $useDefaultCdn := true -}} +{{- with site.Params.mermaid.base -}} + {{- $mermaidBase = . -}} + {{- $useDefaultCdn = false -}} +{{- end -}} + +{{- $mermaidJsAsset := "" -}} +{{- with site.Params.mermaid.js -}} + {{- $mermaidJsAsset = . -}} +{{- end -}} + +{{- /* If only js is set without base, use local asset loading */ -}} +{{- if and $useDefaultCdn (ne $mermaidJsAsset "") -}} + {{- $useDefaultCdn = false -}} +{{- end -}} + +{{- /* Set default CDN base if needed */ -}} +{{- if $useDefaultCdn -}} + {{- $mermaidBase = "https://cdn.jsdelivr.net/npm/mermaid@latest/dist" -}} +{{- end -}} + +{{- $isRemoteBase := or (strings.HasPrefix $mermaidBase "http://") (strings.HasPrefix $mermaidBase "https://") -}} +{{- $minSuffix := cond hugo.IsProduction ".min" "" -}} + +{{- /* JS retrieval: get raw JS from either local asset or remote, then process */ -}} +{{- if $isRemoteBase -}} + {{- $jsPath := cond (ne $mermaidJsAsset "") $mermaidJsAsset (printf "mermaid%s.js" $minSuffix) -}} + {{- $mermaidJsUrl := urls.JoinPath $mermaidBase $jsPath -}} + {{- with try (resources.GetRemote $mermaidJsUrl) -}} + {{- with .Err -}} + {{- errorf "Could not retrieve Mermaid js file from %s. Reason: %s." $mermaidJsUrl . -}} + {{- else with .Value -}} + {{- with resources.Copy (printf "js/mermaid%s.js" $minSuffix) . -}} + {{- $mermaidJs := . | fingerprint -}} + + {{- end -}} + {{- end -}} + {{- end -}} +{{- else if $mermaidJsAsset -}} + {{- with resources.Get $mermaidJsAsset -}} + {{- $mermaidJs := . | fingerprint -}} + + {{- else -}} + {{- errorf "Mermaid js asset not found at %q" $mermaidJsAsset -}} + {{- end -}} +{{- end -}} + +{{- $lightTheme := site.Params.mermaid.lightTheme | default "neutral" -}} +{{- $darkTheme := site.Params.mermaid.darkTheme | default "dark" -}} + + \ No newline at end of file diff --git a/layouts/_partials/scripts/search.html b/layouts/_partials/scripts/search.html new file mode 100644 index 0000000..e69de29