mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-12-25 15:09:28 -05:00
parent
fe94d7f347
commit
6d6fe2c389
@ -23,16 +23,7 @@
|
|||||||
{{- $isHidden := .Params.cover.hidden | default .Site.Params.cover.hiddenInSingle | default .Site.Params.cover.hidden}}
|
{{- $isHidden := .Params.cover.hidden | default .Site.Params.cover.hiddenInSingle | default .Site.Params.cover.hidden}}
|
||||||
{{- partial "cover.html" (dict "cxt" . "IsHome" false "isHidden" $isHidden) }}
|
{{- partial "cover.html" (dict "cxt" . "IsHome" false "isHidden" $isHidden) }}
|
||||||
{{- if (.Param "ShowToc") }}
|
{{- if (.Param "ShowToc") }}
|
||||||
<div class="toc">
|
|
||||||
<details {{if (.Param "TocOpen") }} open{{ end }}>
|
|
||||||
<summary accesskey="c" title="(Alt + C)">
|
|
||||||
<div class="details">{{- i18n "toc" | default "Table of Contents" }}</div>
|
|
||||||
</summary>
|
|
||||||
<div class="inner">
|
|
||||||
{{- partial "toc.html" . }}
|
{{- partial "toc.html" . }}
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
{{- partial "anchored_headings.html" .Content -}}
|
{{- partial "anchored_headings.html" .Content -}}
|
||||||
|
@ -1,20 +1,26 @@
|
|||||||
{{- $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content -}}
|
<div class="toc">
|
||||||
{{- $has_headers := ge (len $headers) 1 -}}
|
<details {{if (.Param "TocOpen") }} open{{ end }}>
|
||||||
{{- if $has_headers -}}
|
<summary accesskey="c" title="(Alt + C)">
|
||||||
|
<div class="details">{{- i18n "toc" | default "Table of Contents" }}</div>
|
||||||
|
</summary>
|
||||||
|
<div class="inner">
|
||||||
|
{{- $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content -}}
|
||||||
|
{{- $has_headers := ge (len $headers) 1 -}}
|
||||||
|
{{- if $has_headers -}}
|
||||||
|
|
||||||
{{- $largest := 6 -}}
|
{{- $largest := 6 -}}
|
||||||
{{- range $headers -}}
|
{{- range $headers -}}
|
||||||
{{- $headerLevel := index (findRE "[1-6]" . 1) 0 -}}
|
{{- $headerLevel := index (findRE "[1-6]" . 1) 0 -}}
|
||||||
{{- $headerLevel := len (seq $headerLevel) -}}
|
{{- $headerLevel := len (seq $headerLevel) -}}
|
||||||
{{- if lt $headerLevel $largest -}}
|
{{- if lt $headerLevel $largest -}}
|
||||||
{{- $largest = $headerLevel -}}
|
{{- $largest = $headerLevel -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- $firstHeaderLevel := len (seq (index (findRE "[1-6]" (index $headers 0) 1) 0)) -}}
|
{{- $firstHeaderLevel := len (seq (index (findRE "[1-6]" (index $headers 0) 1) 0)) -}}
|
||||||
|
|
||||||
{{- $.Scratch.Set "bareul" slice -}}
|
{{- $.Scratch.Set "bareul" slice -}}
|
||||||
<ul>
|
<ul>
|
||||||
{{- range seq (sub $firstHeaderLevel $largest) -}}
|
{{- range seq (sub $firstHeaderLevel $largest) -}}
|
||||||
<ul>
|
<ul>
|
||||||
{{- $.Scratch.Add "bareul" (sub (add $largest .) 1) -}}
|
{{- $.Scratch.Add "bareul" (sub (add $largest .) 1) -}}
|
||||||
@ -74,11 +80,14 @@
|
|||||||
</li>
|
</li>
|
||||||
{{- range seq (sub $lastHeaderLevel $firstHeaderLevel) -}}
|
{{- range seq (sub $lastHeaderLevel $firstHeaderLevel) -}}
|
||||||
{{- if in ($.Scratch.Get "bareul") (add . $firstHeaderLevel) -}}
|
{{- if in ($.Scratch.Get "bareul") (add . $firstHeaderLevel) -}}
|
||||||
</ul>
|
</ul>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
</ul>
|
</ul>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user