jdsteinbach / eleventy-plugin-toc

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

Stringified override options don't parse #2

Open Heydon opened 5 years ago

Heydon commented 5 years ago

Hi! So far so good, except when I pass the JSON string in your example, the template no longer parses (Having trouble writing template: docs/components/card/index.html (TemplateWriterWriteError)).

Any idea what that might be? Thanks.

jdsteinbach commented 4 years ago

Sorry for the (inexcusably) late reply; I'll test this out. Can you provide any other info about this particular Eleventy config?

helmutgranda commented 4 years ago

In my case I have tried two ways and options are not being uptaken by the plugin, they are just being ignored. I was to use UL instead of OL:

const tocOptions = {

    tags: ['h2', 'h3', 'h4'], // which heading tags are selected
    wrapper: 'nav',           // element to put around the root `ol`
    wrapperClass: 'toc-abc',       // class for the element around the root `ol`
    ul: true,
    flat: true, 

}

module.exports = function(eleventyConfig) {

  //Plugins
  eleventyConfig.setLibrary(
    'md',
    markdownIt(mdOptions)
      .use(markdownItAnchor, mdAnchorOpts)
  )

  //eleventyConfig.addPlugin(pluginTOC,tocOptions);

  eleventyConfig.addPlugin(pluginTOC, {
      tags: ['h2', 'h3', 'h4'], // which heading tags are selected
      wrapper: 'nav',           // element to put around the root `ol`
      wrapperClass: 'toc-abc',       // class for the element around the root `ol`
      ul: true,
      flat: false, 
  });
jdsteinbach commented 4 years ago

@helmutgranda Just published 1.1.0 which supports .eleventy.js options in addPlugin

jdsteinbach commented 4 years ago

@Heydon Recent updates also fixed an issue with JSON options in templates. If you're still using this plugin, can you update the version and see if that works for you? Thanks!

jdsteinbach commented 2 years ago

This issue is >1y old and should be resolved by prior work. However, if anyone is still having this issue, I'll give a week to comment, then close. Thanks!