Skip to content

Commit 65c875e

Browse files
committed
Improved toc
1 parent 9c61e4d commit 65c875e

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

content/documentation/PinePhone_Pro/Software/Releases.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: "Releases"
33
draft: false
44
toc: true
5+
toc_depth: 1
56
menu:
67
docs:
78
title:

content/documentation/PineTab/Operating_systems.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "Operating systems"
33
draft: false
4+
toc_depth: 1
45
menu:
56
docs:
67
title:

themes/pinetheme/layouts/documentation/single.html

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,27 @@ <h1>
4444
<nav id="TableOfContents">
4545

4646
{{ $section := .Site.GetPage "section" (printf "/documentation/%s/" .Params.full_section) }}
47+
48+
<!-- Set the filename variable -->
49+
{{ $filename := .File.Filename }}
4750

4851
<div class="toc-head">Table of contents</div>
52+
4953
<ul>
5054
{{ range $section.Pages.ByParam "menu.docs.weight"}}
51-
52-
<li>
53-
<a class="sidebar-nav-subitem" href="#{{ .Title | anchorize }}">{{ .Title }}</a>
54-
<!-- not if "toc: false" is set-->
55-
{{ if not (eq .Params.toc false) }}
56-
<!-- Length limit -->
57-
{{ if lt (.TableOfContents | len ) 800 }}
58-
{{ .TableOfContents }}
55+
<!-- Exclude self -->
56+
{{ if not (eq .File.Filename $filename) }}
57+
<li>
58+
<a class="sidebar-nav-subitem" href="#{{ .Title | anchorize }}">{{ .Title }}</a>
59+
<!-- not if "toc: false" is set-->
60+
{{ if not (eq .Params.toc false) }}
61+
<!-- Length limit -->
62+
{{ if lt (.TableOfContents | len ) 800 }}
63+
{{ .TableOfContents }}
64+
{{ end }}
5965
{{ end }}
60-
{{ end }}
61-
</li>
62-
66+
</li>
67+
{{ end }}
6368
{{ end }}
6469
</ul>
6570

@@ -68,7 +73,11 @@ <h1>
6873
{{ else }}
6974
{{ if ge (len (.TableOfContents)) 33 -}}
7075
<div class="toc-head">Table of contents</div>
71-
{{ .TableOfContents }}
76+
{{ $tocStartLevel := 2 }}
77+
{{ $tocDepth := default 2 .Params.toc_depth }}
78+
{{ $tocEndLevel := add $tocStartLevel (sub $tocDepth 1) }}
79+
{{ $tocOrdered := false }}
80+
{{ .Fragments.ToHTML $tocStartLevel $tocEndLevel $tocOrdered | safeHTML }}
7281
{{ end }}
7382
{{ end }}
7483

0 commit comments

Comments
 (0)