elements
elements copied to clipboard
Documentation: generate a sidebar TOC from page headings
Consider this an half way between a feature request and an idea I had these days, which depends on personal preferences.
I noticed that on the GH page of the author of the first proposed anchor headings solution there is also a liquid script that generates a TOC from the page headings, which accepts also to specify some css classes as parameters, so this one alone could replace the hand made TOC in some elements manual pages (though it might need some small adjustments).
Other than that I thought that it may be good to have the TOC displayed on a side (e.g. on the left) as a widget like an accordion; here as examples some projects that uses that kind of layout:
- https://loopback.io/doc/en/contrib/index.html
- https://idratherbewriting.com/documentation-theme-jekyll/
I did some work to achieve this but if it will be accepted I'll need some help for some minor changes.
Go for it! I support the idea in general. I guess my only concern would be the final aesthetics.
About aesthetics it should appear more or less as is now in my test site/branch, respecting the rest of the theme, you can click randomly on the sidebar on the left at https://redtide.github.io/elements/setup (ignore the dropdown menus on the navbar above, it was just an initial test that should be removed).
It's far for complete and I'm not that smart with js/css so it will take a while:
- the sidebar should start expanded
- the parent headings works only as dropdown, not as link to the section
- in some cases the last nested list is not converted to menu
- arrows or +/- icons for the dropdown menus are missing
- when using a small resolution the sidebar goes mixed above the content instead moving at the top
Closing, this should be included now using Antora for AsciiDoc.