LukasJoswiak/etch

Please add table of contents

xfzka opened this issue · 9 comments

xfzka commented
Please add table of contents

Hi, can you expand on what you mean by this?

xfzka commented

Sorry my English is bad.
This function may call TOC.
Here is the official document https://gohugo.io/content-management/toc/

look like this
image

or this
image

I've attached a PR, please review it and let me know if it's what you were getting at.

xfzka commented

Thank you for you code, but i download branch of the TOC , nothing change, there is no TOC on the article page.

image

image

You’ll need to add {{< toc >}} in the Markdown where you want to insert the table of contents.

xfzka commented

Thank you, add {{< toc >}} to my Markdown article is work very well 😊.

Can you please make the TOC auto generate?

By auto generate do you mean automatically generate for every page without using {{< toc >}}? Or do you mean it should auto generate titles? It should use the header elements in your article to create the table of contents.

xfzka commented

Yes, I mean automatically generate for every page without using {{< toc >}}.
If you don't like this feature,please add a config option to control it, many people like me love TOC feature.

Thanks for the request. I've thought about this, but the reason I added the shortcode to generate a table of contents was to allow it to be placed anywhere on the page. The added complexity of a global table of contents flag would create strange interactions if the page already has the table of contents shortcode, so I'm not going to add this as an option. Closing this issue and merging the associated PR.