diff --git a/assets/scss/components/_toc.scss b/assets/scss/components/_toc.scss index c3259cab..cf7bac4f 100644 --- a/assets/scss/components/_toc.scss +++ b/assets/scss/components/_toc.scss @@ -75,6 +75,35 @@ } } +a.toc-item { + display: block; +} + +a.toc-level-1 { + margin-left: 0; +} + +a.toc-level-2 { + margin-left: 1em; +} + +a.toc-level-3 { + margin-left: 2em; +} + +a.toc-level-4 { + margin-left: 3em; +} + +a.toc-level-5 { + margin-left: 4em; +} + +a.toc-level-6 { + margin-left: 5em; +} + + @if $enable-dark-mode { [data-bs-theme="dark"] { .toc-button { diff --git a/exampleSite/hugo_stats.json b/exampleSite/hugo_stats.json index 64073a03..c1da2108 100644 --- a/exampleSite/hugo_stats.json +++ b/exampleSite/hugo_stats.json @@ -14,7 +14,6 @@ "footer", "form", "h2", - "h3", "head", "hr", "html", @@ -252,6 +251,7 @@ "font-monospace", "footer", "form-control", + "fs-2", "fs-3", "fs-5", "fs-6", @@ -357,7 +357,6 @@ "p-2", "p-3", "p-4", - "pb-2", "pb-3", "pb-4", "pb-5", @@ -373,6 +372,7 @@ "ps-1", "ps-3", "pt-1", + "pt-4", "pt-5", "pt-md-3", "ptw-3", @@ -469,6 +469,8 @@ "toast-header", "toc", "toc-button", + "toc-item", + "toc-level-1", "toc-panel", "toc-sidebar", "toggler-icon", @@ -485,7 +487,6 @@ "w-50" ], "ids": [ - "TableOfContents", "abbr", "accordion", "accordion-0", diff --git a/layouts/partials/assets/persona.html b/layouts/partials/assets/persona.html index 5dc19ed1..51616d78 100644 --- a/layouts/partials/assets/persona.html +++ b/layouts/partials/assets/persona.html @@ -53,7 +53,7 @@ {{- $title := .title -}} {{- $content := .content -}} -

{{ $title }}

+
{{ $title }}
{{ with $content }}

{{ . }}

{{ end -}} {{- end -}} diff --git a/layouts/partials/assets/toc-dropdown.html b/layouts/partials/assets/toc-dropdown.html index f035efe1..c1037ce1 100644 --- a/layouts/partials/assets/toc-dropdown.html +++ b/layouts/partials/assets/toc-dropdown.html @@ -4,36 +4,60 @@ Visit gethinode.com/license for more details. --> + {{ $error := false }} - - -{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "toc" "args" . "group" "partial") }} - {{- errorf "partial [assets/toc-dropdown.html] - Invalid arguments" -}} +{{ $args := partial "utilities/InitArgs.html" (dict "structure" "toc" "args" . "group" "partial") }} +{{ if $args.err }} + {{ partial "utilities/LogErr.html" (dict + "partial" "assets/schema.html" + "msg" "Invalid arguments" + "details" $args.errmsg + "file" page.File + )}} {{ $error = true }} {{ end }} - -{{- $page := .page -}} -{{ $items := len (findRE "(.|\n)*?" $page.TableOfContents) -}} + +{{- $startLevel := or (.Site.Params.navigation.startLevel | int) 2 }} +{{- $endLevel := or (.Site.Params.navigation.endLevel | int) 3 }} +{{- $minNumHeadings := or (.Site.Params.navigation.minNumHeadings | int) 2 }} -{{ if and (not $error) (gt $items 1) -}} -
- {{ partial "assets/button.html" (dict - "title" (T "toc") - "color" "secondary" - "outline" "true" - "class" "toc-button" - "icon" "fas sort" - "justify" "between" - "collapse" "toc-collapse" - "order" "last" - "spacing" false - ) -}} -
+ +{{ if not $error }} + {{ $headings := partial "assets/toc-headings.html" $args.page }} + {{- with $headings }} + {{- if and (not $error) (ge (len .) $minNumHeadings) }} +
+ {{ partial "assets/button.html" (dict + "title" (T "toc") + "color" "secondary" + "outline" "true" + "class" "toc-button" + "icon" "fas sort" + "justify" "between" + "collapse" "toc-collapse" + "order" "last" + "spacing" false + ) -}} +
-