Comments (7)
Thanks for your report. Can you provide some more details in which situations the toc fail? The current toc shortcode is just a wrapper around the default TableOfContents of the current page provided by Goldmark.
from hugo-geekdoc.
Ok I think it does work. First I added to [Params] section of config.toml:
[markup]
[markup.tableOfContents]
endLevel = 6
ordered = false
startLevel = 1
then added a "TableOfContents_Geekdoc" param in the page's frontmatter, then put this in toc.html shortcode:
{{ if .Page.Params.TableOfContents_Geekdoc }}
{{ $tocLevels := default (default 6 .Site.Params.GeekdocToC) .Page.Params.GeekdocToC }}
<div class="gdoc-toc gdoc-toc__level--{{$tocLevels}}">{{ .Page.TableOfContents }}<hr></div>
{{ else }} {{/* default Hugo Toc */}}
<div>{{ .Page.TableOfContents }}<hr></div> {{/* note that .TableOfContents is built-in Hugo var */}}
{{ end }}
Both ways work, I don't see any difference. What would the gdoc-toc class do or display differently ?
Thanks. Sorry to reply slow.
from hugo-geekdoc.
I don't really understand why you have added a TableOfContents_Geekdoc
variable. The ToC is provided by the in-build page variable .Page.TableOfContents
. You could completely ignore the toc
shortcode and use .Page.TableOfContents
directly in your markdown files. If you want to configure the ToC you could use:
[markup]
[markup.tableOfContents]
endLevel = 6
ordered = false
startLevel = 1
The shortcode is just a second way to add a ToC to your markdown pages and has some small benefits:
- it is wrapped by a
div
block and has it's own CSS classes which could be used to customize how the ToC looks like - it adds a small horizontal line at the bottom of the ToC to separate it from the content
- it will place the ToC at whatever position you want it to be on the page
- it has it's own CSS based way to define the ToC level depth because the old markdown renderer was not able to configure the ToC, this feature was introduced by Goldmark
So in general you have two ways to use the ToC. You could choose between the shortcode wrapper or the plain build-in .Page.TableOfContents
variable. You could also choose between the methods to control the ToC depth. One option is to use the default Goldmark config options (see above) or the custom CSS solution controlled by the GeekdocToC
variable but this one only works with the shortcode because it required the injected CSS classes gdoc-toc gdoc-toc__level--*
. For example GeekdocToC = 3
will display ToC level 1-3.
from hugo-geekdoc.
I added the var for testing purposes, just to quickly switch back and forth (see the first {{if ... }} in toc.html).
Thanks for the benefits list. Being able to control depth level and place the toc as needed are definitely useful.
You mention injected classes. I found the .gdoc-toc{} definition in _base.scss but where are the __level--N classes defined ?
Thanks.
from hugo-geekdoc.
It's also in _base.scss
https://github.com/thegeeklab/hugo-geekdoc/blob/master/src/sass/_base.scss#L462.
from hugo-geekdoc.
Ok got it. I needed to bone up on the "&" selector.
from hugo-geekdoc.
As you can see on the file ending thats SASS syntax. I'm going to close the issue.
from hugo-geekdoc.
Related Issues (20)
- Feature Request: Open External Links in New Tab
- FlexSearch does not work on Safari HOT 6
- Feature Request: Built-In Versioning/Selector Feature HOT 4
- Provide a way to show "Next" and "Previous" links on a page HOT 9
- Codeblock copy adds empty lines HOT 13
- Table of Contents shortcode needs better documentation on difference between html and raw HOT 4
- TOC-Tree sorts alphabettically instead of how the site sorts it HOT 8
- Collapse Arrow-Down icon is hidden with Menu Bundle HOT 2
- Category needs to have a ref in bundle menu in order for it to be collapseable HOT 1
- Unable to use expand or tabs with mermaid HOT 5
- Google analytics support HOT 1
- Do not use`.Site.BaseURL` HOT 2
- 404 render error HOT 7
- Goldmark renderer must be marked with "unsafe = true" to allow nested shortcodes HOT 2
- Feature Request: Support for beta mermaid diagrams
- Generating website fails if timeout is not increased - is this expected?
- How to set a url path containing "index"? HOT 1
- Freeze menu and title bar?
- Provide an audio shortcode
- Make UI for expandable shortcodes clearer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hugo-geekdoc.