forked from drowl87/hextra_mirror
chore: add toc in section tree json
This commit is contained in:
parent
78ce7c2f2e
commit
5842f893a3
@ -15,6 +15,7 @@
|
|||||||
{
|
{
|
||||||
"title": "{{ .LinkTitle | default .File.BaseFileName }}",
|
"title": "{{ .LinkTitle | default .File.BaseFileName }}",
|
||||||
"link": "{{ .RelPermalink }}",
|
"link": "{{ .RelPermalink }}",
|
||||||
|
"toc": {{ partial "sidebar/section-page-toc" . }},
|
||||||
"open": {{ .Params.sidebar.open | default false }}
|
"open": {{ .Params.sidebar.open | default false }}
|
||||||
{{- if .IsSection }},
|
{{- if .IsSection }},
|
||||||
"section": [
|
"section": [
|
||||||
@ -29,4 +30,22 @@
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ return ($data | jsonify) }}
|
{{- define "partials/sidebar/section-page-toc" -}}
|
||||||
|
{{/* Get level 2 headings list used mainly for mobile navigation */}}
|
||||||
|
[
|
||||||
|
{{- with .Fragments.Headings -}}
|
||||||
|
{{/* Loop over level 1 headings */}}
|
||||||
|
{{- range . }}
|
||||||
|
{{- with .Headings }}
|
||||||
|
{{ $headings := . }}
|
||||||
|
{{- range $index, $heading := $headings }}
|
||||||
|
{{ $heading.Title | jsonify (dict "noHTMLEscape" true) }}
|
||||||
|
{{- if not (ge $index (sub (len $headings) 1)) }},{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
]
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ return ($data | jsonify (dict "noHTMLEscape" true)) }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user