fix: update TOC handling logic to use showToc flag

This commit is contained in:
Cell
2025-12-25 17:16:07 +08:00
parent 3482b8bf08
commit 8ffb9a9563
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v0.4.0-alpha.3-20251225090302-dcc5e32c" -}}
{{- hugo.Store.Set "version" "v0.4.0-alpha.3-20251225091608-3482b8bf" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}
+1 -1
View File
@@ -17,7 +17,7 @@
</div>
{{- end -}}
{{- /* toc dialog button */ -}}
{{- if .Page.Store.Get "hasToc" -}}
{{- if .Store.Get "showToc" -}}
<div id="toc-drawer-button" class="fixed-button toc-drawer-button d-none{{ with $params.password }} encrypted-hidden{{ end }}" role="button" aria-label="{{ T `single.contents` }}">
{{- dict "Class" "fa-solid fa-bars fa-fw" | partial "plugin/icon.html" -}}
</div>
+1 -1
View File
@@ -9,6 +9,7 @@
{{- $toc := .Store.Get "toc" -}}
{{- $tableOfContents := .Fragments.ToHTML ($toc.startlevel | int) ($toc.endlevel | int) ($toc.ordered | default false) -}}
{{- $showToc := $toc.enable | and (ne $tableOfContents `<nav id="TableOfContents"></nav>`) -}}
{{- .Store.Set "showToc" $showToc -}}
{{- $tableOfContents = dict "Content" $tableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
<aside class="aside-collection animate__animated animate__fadeIn animate__faster" aria-label="{{ T "collections" }}">
@@ -234,7 +235,6 @@
{{- /* TOC Dialog */ -}}
{{- if $showToc -}}
{{- .Page.Store.Set "hasToc" true -}}
<dialog id="toc-dialog" aria-labelledby="toc-dialog-title" role="dialog">
<div class="toc">
<h2 class="toc-title">{{ T "single.contents" }}</h2>