mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
taxonomy: fix toc generation for taxonomy and term pages #705
This commit is contained in:
parent
215ab9c9d2
commit
7516352b52
2 changed files with 68 additions and 4 deletions
|
@ -2,8 +2,40 @@
|
||||||
<nav id="TableOfContents">
|
<nav id="TableOfContents">
|
||||||
<ul>
|
<ul>
|
||||||
{{- $lastCapital := "" }}
|
{{- $lastCapital := "" }}
|
||||||
{{- range .Data.Terms.Alphabetical }}
|
{{- $terms := slice }}
|
||||||
{{- $capital := substr .Page.Title 0 1 | upper }}
|
{{- range .Data.Terms }}
|
||||||
|
{{- $terms = $terms | append (dict "Title" (default .Page.Data.Term .Page.Title) "Term" . )}}
|
||||||
|
{{- end }}
|
||||||
|
{{- range sort $terms ".Title" }}
|
||||||
|
{{- $capital := substr .Title 0 1 | upper }}
|
||||||
|
{{- $len := 0 }}
|
||||||
|
{{- range .Term.Pages }}
|
||||||
|
{{- $c:=""}}{{/* count pages of term */}}
|
||||||
|
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
||||||
|
{{- $len = add $len 1 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $len }}
|
||||||
|
{{- if ne $lastCapital $capital }}
|
||||||
|
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
|
||||||
|
{{- end }}
|
||||||
|
{{- $lastCapital = $capital }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{{- else if eq .Kind "term" }}
|
||||||
|
<nav id="TableOfContents">
|
||||||
|
<ul>
|
||||||
|
{{- $lastCapital := "" }}
|
||||||
|
{{- $pages := slice }}
|
||||||
|
{{- range .Pages }}
|
||||||
|
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
||||||
|
{{- $pages = $pages | append (dict "Title" .Title "Page" . )}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range sort $pages ".Title" }}
|
||||||
|
{{- $capital := substr .Title 0 1 | upper }}
|
||||||
{{- if ne $lastCapital $capital }}
|
{{- if ne $lastCapital $capital }}
|
||||||
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
|
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -2,8 +2,40 @@
|
||||||
<nav id="TableOfContents">
|
<nav id="TableOfContents">
|
||||||
<ul>
|
<ul>
|
||||||
{{- $lastCapital := "" }}
|
{{- $lastCapital := "" }}
|
||||||
{{- range .Data.Terms.Alphabetical }}
|
{{- $terms := slice }}
|
||||||
{{- $capital := substr .Page.Title 0 1 | upper }}
|
{{- range .Data.Terms }}
|
||||||
|
{{- $terms = $terms | append (dict "Title" (default .Page.Data.Term .Page.Title) "Term" . )}}
|
||||||
|
{{- end }}
|
||||||
|
{{- range sort $terms ".Title" }}
|
||||||
|
{{- $capital := substr .Title 0 1 | upper }}
|
||||||
|
{{- $len := 0 }}
|
||||||
|
{{- range .Term.Pages }}
|
||||||
|
{{- $c:=""}}{{/* count pages of term */}}
|
||||||
|
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
||||||
|
{{- $len = add $len 1 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $len }}
|
||||||
|
{{- if ne $lastCapital $capital }}
|
||||||
|
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
|
||||||
|
{{- end }}
|
||||||
|
{{- $lastCapital = $capital }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{{- else if eq .Kind "term" }}
|
||||||
|
<nav id="TableOfContents">
|
||||||
|
<ul>
|
||||||
|
{{- $lastCapital := "" }}
|
||||||
|
{{- $pages := slice }}
|
||||||
|
{{- range .Pages }}
|
||||||
|
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
||||||
|
{{- $pages = $pages | append (dict "Title" .Title "Page" . )}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range sort $pages ".Title" }}
|
||||||
|
{{- $capital := substr .Title 0 1 | upper }}
|
||||||
{{- if ne $lastCapital $capital }}
|
{{- if ne $lastCapital $capital }}
|
||||||
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
|
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in a new issue