Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stringified override options don't parse #2

Open
Heydon opened this issue Oct 9, 2018 · 5 comments
Open

Stringified override options don't parse #2

Heydon opened this issue Oct 9, 2018 · 5 comments

Comments

@Heydon
Copy link

Heydon commented Oct 9, 2018

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
Copy link
Owner

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

  • What template option are you using?
  • Can you provide an example of the stringified JSON option object you're passing in?

@helmutgranda
Copy link

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
Copy link
Owner

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

@jdsteinbach
Copy link
Owner

@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
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants