Skip to content

Commit

Permalink
🐛 Fix: toc data patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Oct 2, 2024
1 parent 9c440df commit 58cfa55
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 6 additions & 1 deletion layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{{- /* Read the config and format */ -}}
{{- $params := .Page.Params | merge site.Params.page -}}
{{- $ordered := $params.toc.ordered | and $params.heading.number.enable -}}
{{- /* Toc data patch */ -}}
{{- $toc := $params.toc -}}
{{- if not (reflect.IsMap $toc) -}}
{{- $toc = dict "enable" $toc | merge site.Params.page.toc -}}
{{- end -}}
{{- $ordered := $toc.ordered | and $params.heading.number.enable -}}
{{- $h1Format := $params.heading.number.format.h1 | default "{title}" -}}
{{- $h2Format := $params.heading.number.format.h2 | default "{h2} {title}" -}}
{{- $h3Format := $params.heading.number.format.h3 | default "{h2}.{h3} {title}" -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/init/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.13-53f221b7" -}}
{{- .Scratch.Set "version" "v0.3.13-9c440df3" -}}
{{- .Scratch.Set "this" dict -}}

{{- partial "init/detection-env.html" . -}}
Expand Down
6 changes: 2 additions & 4 deletions layouts/partials/init/patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

{{- /* Toc data patch */ -}}
{{- $toc := $params.toc -}}
{{- if eq $toc true -}}
{{- $toc = dict "enable" true | merge .Site.Params.page.toc -}}
{{- else if eq $toc false -}}
{{- $toc = dict "enable" false | merge .Site.Params.page.toc -}}
{{- if not (reflect.IsMap $toc) -}}
{{- $toc = dict "enable" $toc | merge .Site.Params.page.toc -}}
{{- end -}}
{{- .Scratch.Set "toc" $toc -}}

Expand Down
4 changes: 2 additions & 2 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{- $title := cond (.Param "capitalizeTitles") (title .Title) .Title -}}
{{- $params := partial "function/params.html" -}}
{{- $toc := .Scratch.Get "toc" -}}
{{- $tableOfContents := .Fragments.ToHTML ($toc.startLevel | int) ($toc.endLevel | int) ($toc.ordered | default false) -}}
{{- $tableOfContents := .Fragments.ToHTML ($toc.startlevel | int) ($toc.endlevel | int) ($toc.ordered | default false) -}}
{{- $showToc := $toc.enable | and (ne $tableOfContents `<nav id="TableOfContents"></nav>`) -}}

<aside class="aside-collection animate__animated animate__fadeIn animate__faster" aria-label="{{ T "collections" }}">
Expand Down Expand Up @@ -148,7 +148,7 @@ <h1 class="single-title animate__animated animate__flipInX">

{{- /* Static TOC */ -}}
{{- if $showToc -}}
<div class="details toc{{ with $params.password }} encrypted-hidden{{ end }}" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ else }}false{{ end }}">
<div class="details toc{{ with $params.password }} encrypted-hidden{{ end }}" id="toc-static" data-kept="{{ if $toc.keepstatic }}true{{ else }}false{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "single.contents" }}</span>
<span>{{ dict "Class" "details-icon fa-solid fa-angle-right" | partial "plugin/icon.html" }}</span>
Expand Down

0 comments on commit 58cfa55

Please sign in to comment.