jdsteinbach / eleventy-plugin-toc

11ty plugin to generate a TOC from page content
61 stars 19 forks source link

Feature request: Ability to append or prepend TOC items #40

Open LeaVerou opened 1 year ago

LeaVerou commented 1 year ago

Thanks for making this plugin!

I tried to use it today to replace some in-house code that generated TOCs client-side. The issue I run into was that we are also adding sections with headings in the same template, which of course are not reflected in the TOC as they are not part of content. It would be nice to be able to add TOC items for these manually.

One possible API for this would be to deprecate the ul option and replace it with a listElement option that takes values like ul or 'ol, but could also take the empty string for no list. Then the consumer of this plugin can add the <ol>/<ul> manually and prepend/append any additional items.