lukeorth / poison

Professional Hugo theme for dev bloggers. Based on Mdo's classic Hyde theme.
https://poison.lukeorth.com
GNU General Public License v3.0
199 stars 98 forks source link

Allows users to supply a flag in the frontmatter to disable the table… #111

Closed JonAugust closed 1 year ago

JonAugust commented 1 year ago

This change allows a user to supply a tag in the frontmatter for a post that will disable the table of contents. For example:

hideToc: true

will disable the table of contents.

hideToc: false

will display the table of contents if you want to be explicit. I used the verb hide to facilitate cases where the flag is not explicitly set - which will be the case for all existing posts. The absence of the flag will display the table of contents.

If accepted and merged, this would close #110

lukeorth commented 1 year ago

Thank you, @JonAugust -- this looks great. Thank you for the contribution! :slightly_smiling_face:

JonAugust commented 1 year ago

Thank you very much for merging this. (my first OS PR). I had a couple of questions:

Thanks again!

lukeorth commented 1 year ago

Congrats on your first OS PR! :tada:

To your first bullet point -- that was my bad. Being able to show/hide the ToC on a per-post basis makes sense to me. I'll probably keep the site-wide option too (in case someone doesn't want any ToC on their site), but also add the per-post option. Good catch!

To your second bullet point -- yes, this just removes unnecessary JavaScript. It only works at the site-wide level though (if you set hideToc: true in your config.toml). Essentially, if someone doesn't want any ToC, then there's no need to download the JavaScript for it. This helps with page load times. The script is tiny, so it's not a huge boost in performance, but it's a small optimization nonetheless.

lukeorth commented 1 year ago

@JonAugust, I just merged this PR #112 to enable you to specify hideToc on a per-post basis in the frontmatter. Hope it helps!

Let me know if you have any other questions/comments/suggestions. :+1:

JonAugust commented 1 year ago

@lukeorth This is perfect. Thank you for this!