jdsteinbach / eleventy-plugin-toc

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

Add Custom CSS Classes #42

Open aress31 opened 1 year ago

aress31 commented 1 year ago

So far to add a custom CSS class to the TOC is to use the following workaround:

  eleventyConfig.addPlugin(toc, {
    wrapper: undefined,
  });

  eleventyConfig.addFilter("bootstrapToc", (tocHtml) => {
    if (tocHtml) {
      return tocHtml
        .replace(/<ol>/g, `<ol class="list-group">`)
        .replace(/<li>/g, `<li class="list-group-item">`);
    }
    return tocHtml;
  });

Would be nice to have a built-in feature to achieve the same results.