diff --git a/apps/test/content/posts/katex-test.md b/apps/test/content/posts/katex-test.md index 303629d5..ee0da8de 100644 --- a/apps/test/content/posts/katex-test.md +++ b/apps/test/content/posts/katex-test.md @@ -1,5 +1,5 @@ --- -title: KaTex Test +title: KaTeX Test date: 2025-09-15T21:05:17+08:00 collections: - Tests @@ -9,7 +9,7 @@ tags: - Math --- -Testing KaTex rendering in FixIt theme. +Testing $\KaTeX$ rendering in FixIt theme. diff --git a/apps/test/content/posts/mathjax-test.md b/apps/test/content/posts/mathjax-test.md index 1c98c450..08acdefe 100644 --- a/apps/test/content/posts/mathjax-test.md +++ b/apps/test/content/posts/mathjax-test.md @@ -24,7 +24,7 @@ math: arrowdel: false --- -Testing MathJax rendering in FixIt theme. +Testing $\text{MathJax}$ rendering in FixIt theme. diff --git a/layouts/_markup/render-passthrough.html b/layouts/_markup/render-passthrough.html index 227eda84..8dcaef8e 100644 --- a/layouts/_markup/render-passthrough.html +++ b/layouts/_markup/render-passthrough.html @@ -29,6 +29,9 @@ {{- else }} {{- .Value }} {{- $.Page.Store.Set "hasKaTeX" true -}} + {{- if eq hugo.Context.MarkupScope "home" -}} + {{- site.Home.Store.Set "hasKaTeX" true -}} + {{- end -}} {{- end }} {{- end -}} {{- else if eq $math.type "mathjax" -}} @@ -37,6 +40,10 @@ {{- else -}} ${{ .Inner }}$ {{- end -}} + {{- $.Page.Store.Set "hasMathJax" true -}} + {{- if eq hugo.Context.MarkupScope "home" -}} + {{- site.Home.Store.Set "hasMathJax" true -}} + {{- end -}} {{- end -}} {{- else -}} {{- /* Regular passthrough rendering */ -}} diff --git a/layouts/_partials/assets.html b/layouts/_partials/assets.html index a8e6e6e6..ef44d107 100644 --- a/layouts/_partials/assets.html +++ b/layouts/_partials/assets.html @@ -93,51 +93,49 @@ {{- /* Mathematical formulas */ -}} {{- $math := .Store.Get "math" -}} -{{- if $math.enable -}} - {{- /* KaTeX */ -}} - {{- if (eq $math.type "katex") | and (.Store.Get "hasKaTeX") -}} - {{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}} - {{- dict "Source" $source "Fingerprint" $fingerprint "Preload" true | dict "Page" . "Data" | partial "store/style.html" -}} - {{- /* Copy-tex extension */ -}} - {{- if $math.katex.copyTex -}} - {{- $source := $cdn.katexCopyTexJS | default "lib/katex/copy-tex.min.js" -}} - {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} - {{- end -}} +{{- /* KaTeX */ -}} +{{- if .Store.Get "hasKaTeX" -}} + {{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}} + {{- dict "Source" $source "Fingerprint" $fingerprint "Preload" true | dict "Page" . "Data" | partial "store/style.html" -}} + {{- /* Copy-tex extension */ -}} + {{- if $math.katex.copyTex -}} + {{- $source := $cdn.katexCopyTexJS | default "lib/katex/copy-tex.min.js" -}} + {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- end -}} +{{- end -}} - {{- /* MathJax */ -}} - {{- if eq $math.type "mathjax" -}} - {{- $mathjax := $math.mathjax -}} - {{- $source := "js/lib/mathjax.js" -}} - {{- $options := dict "targetPath" "js/lib/mathjax.min.js" "minify" hugo.IsProduction -}} - {{- $mathjaxOptsConfig := $mathjax.options | default dict -}} - {{- $mathjaxOpts := dict -}} - {{- if eq $mathjaxOptsConfig.enableMenu false -}} - {{- $mathjaxOpts = dict "enableMenu" false | merge $mathjaxOpts -}} - {{- end -}} - {{- with $mathjaxOptsConfig.ignoreHtmlClass -}} - {{- $mathjaxOpts = dict "ignoreHtmlClass" . | merge $mathjaxOpts -}} - {{- end -}} - {{- with $mathjaxOptsConfig.skipHtmlTags -}} - {{- $mathjaxOpts = dict "skipHtmlTags" . | merge $mathjaxOpts -}} - {{- end -}} - {{- with $mathjaxOptsConfig.includeHtmlTags -}} - {{- $mathjaxOpts = dict "includeHtmlTags" . | merge $mathjaxOpts -}} - {{- end -}} - {{- $params := dict - "cdn" $mathjax.cdn - "tex" ($mathjax.tex | default dict) - "packages" ($mathjax.packages | default dict) - "macros" ($mathjax.macros | default dict) - "loader" ($mathjax.loader | default dict) - "options" $mathjaxOpts - -}} - {{- $options = dict "params" $params | merge $options -}} - {{- if not hugo.IsProduction -}} - {{- $options = dict "sourceMap" "external" | merge $options -}} - {{- end -}} - {{- dict "Source" $source "Build" $options "Fingerprint" $fingerprint "Async" true "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} +{{- /* MathJax */ -}} +{{- if .Store.Get "hasMathJax" -}} + {{- $mathjax := $math.mathjax -}} + {{- $source := "js/lib/mathjax.js" -}} + {{- $options := dict "targetPath" "js/lib/mathjax.min.js" "minify" hugo.IsProduction -}} + {{- $mathjaxOptsConfig := $mathjax.options | default dict -}} + {{- $mathjaxOpts := dict -}} + {{- if eq $mathjaxOptsConfig.enableMenu false -}} + {{- $mathjaxOpts = dict "enableMenu" false | merge $mathjaxOpts -}} {{- end -}} + {{- with $mathjaxOptsConfig.ignoreHtmlClass -}} + {{- $mathjaxOpts = dict "ignoreHtmlClass" . | merge $mathjaxOpts -}} + {{- end -}} + {{- with $mathjaxOptsConfig.skipHtmlTags -}} + {{- $mathjaxOpts = dict "skipHtmlTags" . | merge $mathjaxOpts -}} + {{- end -}} + {{- with $mathjaxOptsConfig.includeHtmlTags -}} + {{- $mathjaxOpts = dict "includeHtmlTags" . | merge $mathjaxOpts -}} + {{- end -}} + {{- $params := dict + "cdn" $mathjax.cdn + "tex" ($mathjax.tex | default dict) + "packages" ($mathjax.packages | default dict) + "macros" ($mathjax.macros | default dict) + "loader" ($mathjax.loader | default dict) + "options" $mathjaxOpts + -}} + {{- $options = dict "params" $params | merge $options -}} + {{- if not hugo.IsProduction -}} + {{- $options = dict "sourceMap" "external" | merge $options -}} + {{- end -}} + {{- dict "Source" $source "Build" $options "Fingerprint" $fingerprint "Async" true "Defer" true | dict "Page" . "Data" | partial "store/script.html" -}} {{- end -}} {{- /* mermaid */ -}} diff --git a/layouts/_partials/init/index.html b/layouts/_partials/init/index.html index 2b68f666..dc0aaacd 100644 --- a/layouts/_partials/init/index.html +++ b/layouts/_partials/init/index.html @@ -1,4 +1,4 @@ -{{- hugo.Store.Set "version" "v0.4.0-alpha.2-20250915130208-81c333ca" -}} +{{- hugo.Store.Set "version" "v0.4.0-alpha.2-20250915151330-1f0762dd" -}} {{- .Store.Set "this" dict -}} {{- partial "init/detection-env.html" . -}}