mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-22 03:19:25 +00:00
#52, Allow to set max showed levels of ToC. e.g. BookToC=3
This commit is contained in:
parent
6d64cc708e
commit
e452a7beda
15
README.md
15
README.md
@ -15,6 +15,10 @@
|
||||
- [Shortcodes](#shortcodes)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
## Breaking changes
|
||||
|
||||
> ⚠️ At the moment theme is under development, breaking changes might happen.
|
||||
|
||||
## Features
|
||||
|
||||
- Clean simple design
|
||||
@ -123,9 +127,10 @@ enableGitInfo = true
|
||||
disableKinds = ['taxonomy', 'taxonomyTerm']
|
||||
|
||||
[params]
|
||||
# (Optional, default true) Show or hide table of contents globally
|
||||
# (Optional, default 6) Set how many table of contents levels to be showed on page.
|
||||
# Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/)
|
||||
# You can also specify this parameter per page in front matter
|
||||
BookShowToC = true
|
||||
BookToC = 3
|
||||
|
||||
# (Optional, default none) Set leaf bundle to render as side menu
|
||||
# When not specified file structure and weights will be used
|
||||
@ -174,8 +179,8 @@ bookFlatSection = true
|
||||
# (Optional) Set true to hide page or section from side menu (if BookMenuBundle not set)
|
||||
bookHidden = true
|
||||
|
||||
# (Optional) Set true to hide table of contents, overrides global value
|
||||
bookShowToC = false
|
||||
# (Optional) Set how many levels of ToC to show. use 'false' to hide ToC completely
|
||||
bookToC = 3
|
||||
```
|
||||
|
||||
### Partials
|
||||
@ -235,7 +240,7 @@ Organize text in 2 or more columns to use space efficiently.
|
||||
# Mid Content Lorem markdownum insigne... <--->
|
||||
<!-- magic sparator, between columns -->
|
||||
|
||||
# Right Content Lorem markdownum insigne...
|
||||
# Right Content Lorem markdownum insigne...
|
||||
{{< /columns >}}
|
||||
```
|
||||
|
||||
|
@ -147,6 +147,16 @@ ul.pagination {
|
||||
nav > ul > li:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
// Classes to hide nested levels of ToC (can be replaced by @for, but it's more clear like this)
|
||||
&.level-1 ul ul,
|
||||
&.level-2 ul ul ul,
|
||||
&.level-3 ul ul ul ul,
|
||||
&.level-4 ul ul ul ul ul,
|
||||
&.level-5 ul ul ul ul ul ul,
|
||||
&.level-6 ul ul ul ul ul ul ul {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.book-footer {
|
||||
|
@ -15,9 +15,10 @@ enableGitInfo = true
|
||||
pygmentsCodeFences = true
|
||||
|
||||
[params]
|
||||
# (Optional, default true) Show or hide table of contents globally
|
||||
# (Optional, default 6) Set how many table of contents levels to be showed on page.
|
||||
# Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/)
|
||||
# You can also specify this parameter per page in front matter
|
||||
BookShowToC = true
|
||||
BookToC = 3
|
||||
|
||||
# (Optional, default none) Set leaf bundle to render as side menu
|
||||
# When not specified file structure and weights will be used
|
||||
|
@ -15,9 +15,10 @@ enableGitInfo: true
|
||||
pygmentsCodeFences: true
|
||||
|
||||
params:
|
||||
# (Optional, default true) Show or hide table of contents globally
|
||||
# (Optional, default 6) Set how many table of contents levels to be showed on page.
|
||||
# Use false/off to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/)
|
||||
# You can also specify this parameter per page in front matter
|
||||
BookShowToC: true
|
||||
BookToC: 3
|
||||
|
||||
# (Optional, default none) Set leaf bundle to render as side menu
|
||||
# When not specified file structure and weights will be used
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
{"Target":"book.min.1009ab9f4daf8375016f8f76fc100311154512dbc6cc21faa1282132e83dad16.css","MediaType":"text/css","Data":{"Integrity":"sha256-EAmrn02vg3UBb492/BADERVFEtvGzCH6oSghMug9rRY="}}
|
||||
{"Target":"book.min.3c69b4506bc4a8da260ab28ed0c14019a49435aed9fd20517f353987fa0f60ec.css","MediaType":"text/css","Data":{"Integrity":"sha256-PGm0UGvEqNomCrKO0MFAGaSUNa7Z/SBRfzU5h/oPYOw="}}
|
@ -23,7 +23,7 @@
|
||||
|
||||
{{ define "book-section" }}
|
||||
{{ with .Section }}
|
||||
<li {{ if .Params.bookFlatSection}} class="book-section-flat" {{ end }}>
|
||||
<li {{ if .Params.BookFlatSection}} class="book-section-flat" {{ end }}>
|
||||
{{ if .Content }}
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
{{ else }}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<nav role="navigation">
|
||||
<nav>
|
||||
{{ partial "docs/brand" . }}
|
||||
{{ partial "docs/inject/menu-before" . }}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{ $showToC := default (default true .Site.Params.BookShowToC) .Params.bookshowtoc }}
|
||||
{{ if and ($showToC) (.Page.TableOfContents) }}
|
||||
<aside class="book-toc fixed">
|
||||
{{ $tocLevels := default (default 6 .Site.Params.BookToC) .Params.BookToC }}
|
||||
{{ if and $tocLevels .Page.TableOfContents }}
|
||||
<aside class="book-toc level-{{$tocLevels}} fixed">
|
||||
{{ .Page.TableOfContents }}
|
||||
</aside>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user