NJAldwin / eleventy-plugin-gen-favicons

Favicon generator plugin for eleventy
MIT License
15 stars 4 forks source link

Error when passing arguments to shortcode #1

Closed silveltman closed 1 year ago

silveltman commented 2 years ago

I'm unable to pass arguments in the shortcode. I'm using liquid, but also tried njk.

Error:

Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble writing template: "_site/components/index.html" (via EleventyTemplateError)
[11ty] 2. invalid syntax at line 1 col 25:
[11ty]
[11ty]   favicon appleIconBgColor='blue'
[11ty]                           ^, file:C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\src\_includes\head.liquid, line:35, col:5 (via RenderError)   
[11ty] 3. invalid syntax at line 1 col 25:
[11ty]
[11ty]   favicon appleIconBgColor='blue'
[11ty]                           ^ (via Error)
[11ty]
[11ty] Original error stack trace: Error: invalid syntax at line 1 col 25:
[11ty]
[11ty]   favicon appleIconBgColor='blue'
[11ty]                           ^
[11ty]     at Lexer._token (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\moo\moo.js:533:13)
[11ty]     at Lexer.next (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\moo\moo.js:480:19)
[11ty]     at Function.parseArguments (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\@11ty\eleventy\src\Engines\Liquid.js:121:21)       
[11ty]     at async Object.render (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\@11ty\eleventy\src\Engines\Liquid.js:145:26)
[11ty]     at async TemplateLayout.render (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\@11ty\eleventy\src\TemplateLayout.js:161:25)   
[11ty]     at async Template.renderPageEntry (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\@11ty\eleventy\src\Template.js:853:17)      
[11ty]     at async C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\@11ty\eleventy\src\Template.js:883:21
[11ty]     at async Promise.all (index 0)
[11ty]     at async Promise.all (index 1)
[11ty]     at async Eleventy.executeBuild (C:\Users\silve\websites\11ty\starters\11ty-cloudcannon-starter\node_modules\@11ty\eleventy\src\Eleventy.js:1003:13)        
[11ty] Wrote 0 files in 0.05 seconds (v1.0.1)
NJAldwin commented 2 years ago

Thanks for the report, can you include the exact syntax you're using in the file?

From the error, it looks like you may be doing {% favicon appleIconBgColor='blue' %}

if this is the case, two things to try:

like so:

{% favicons 'path/to/my/favicon.svg', appleIconBgColor='blue' %}

silveltman commented 2 years ago

Below a syntax that gives the error given above:

{% favicons '/assets/img/uploads/favicon-32x32.png' appleIconBgColor='blue' %}

NJAldwin commented 2 years ago

@silveltman please try adding a comma after the favicon, like so:

{% favicons '/assets/img/uploads/favicon-32x32.png', appleIconBgColor='blue' %}
NJAldwin commented 1 year ago

I am going to close this, as it appears to be a syntax issue and has been stale for 5 months. Please reopen if you are still seeing issues which are not solved by using the correct syntax.

mortendk commented 1 year ago

liquid wont take a named argument so to make it work with liquid we can use the rendertemplate https://www.11ty.dev/docs/plugins/render/

so something like this

{% renderTemplate "njk", variablewiththeiconpathinit %}

 {% favicons icon, appleIconBgColor='red',appleIconPadding=10, generateManifest=false %}

{% endrenderTemplate %}