carpentries / tnd-carpentries-working

The Carpentries new website BEFORE the Hugo theme was packaged out. Not currently maintained.
https://tnd-carpentries-website.netlify.app/
0 stars 0 forks source link

Option to include ToC in a page content #35

Closed maneesha closed 5 months ago

maneesha commented 5 months ago

We can include a ToC in a sidebar build from H2 elements using the toc widget. Can we also have the option for a ToC in a certain page directly? I've tried using the same widget in the page markdown file but that does not work.

Here's an example of how we do this in Jekyll using the toc plugin.
Current page: https://carpentries.org/workshop_faq/ Source code: https://github.com/carpentries/carpentries.org/blob/main/pages/workshop_faq.md?plain=1

AdamChlan commented 5 months ago

@maneesha How many levels (h2, h3, h4, etc) do you need to support in this TOC example?

maneesha commented 5 months ago

Does the level need to be fixed? If so, it should go through H3.

AdamChlan commented 5 months ago

The number of levels to support is a global setting. We will set it out as far as H3, and we can hide any H3's in the sidebar TOC, since it seems like we only want to show H2 there.

maneesha commented 5 months ago

@AdamChlan Will the ToC work alongside collapsible acccordion styles?

AdamChlan commented 5 months ago

@maneesha can you define "work alongside"? The way the TOC will work when inside a page, is that links will be generated to H2 and H3's in the .md file. I don't anticipate being able to link directly to an accordion though. An H2 of H3 just above it would work though.

AdamChlan commented 5 months ago

@maneesha you can now add a TOC to a page using the following shortcode:

{{< toc >}}