vidhill / fortawesome-brands-svg-11ty-shortcode

Allows fortawesome brand icons svgs to be embedded in eleventy templates
MIT License
0 stars 1 forks source link

Shortcode not outputting anything #8

Closed dannystaple closed 1 year ago

dannystaple commented 1 year ago

I'm somewhat new to 11ty (having come from the Jekyll ssg), and I'm having difficulty with this plugin. I've installed the tool as a dev dependency npm install --save-dev @vidhill/fortawesome-brands-11ty-shortcode - matching most of the other 11ty tools I have installed. In the top of the .eleventy.js file I've imported it:

const {
    fortawesomeBrandsPlugin,
} = require('@vidhill/fortawesome-brands-11ty-shortcode');

And in the settings:

module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(fortawesomeBrandsPlugin);
  .. my other shortcodes/config/filters ...
}```

I am using it in a liquid template:
```liquid
        <li><a href="https://www.youtube.com/orionrobots" class="list-group-item">{% fortawesomeBrand youtube-square %} Youtube</a></li>

I test this with a command npm run serve, in my package.json that is:

    "serve": "npx @11ty/eleventy --serve --quiet"

When I then inspect the page, at the intended .list-group-item element I see nothing there at all:

<li><a href="https://www.youtube.com/orionrobots" class="list-group-item"> Youtube</a></li>

I've tried to see if it would generate an issue if I suggest a non-existent icon:

{% fortawesomeBrand asgsdkgjshg %} 

Nothing happened - no change here. I used console.log with the fortawesomeBrandsPlugin variable, and see that it is a function. I'd love any help you have on this one, as it beats what my live site is doing - loading the whole font-awesome css for 4 icons. 🤦

vidhill commented 1 year ago

Hello, I'm only on my phone at the moment, I will try to look at this later tonight.

In the meantime, here is my config,

https://github.com/vidhill/yan-static-site-experiment/blob/main/.eleventy.js

vidhill commented 1 year ago

One thing worth checking is that in my example, I was using nunjucks templates, I wonder if the syntax for shortcodes is different for liquid templates? Perhaps?

dannystaple commented 1 year ago

Ok - I found it. And feel a bit dumb. It should've been in quotes, otherwise it's looking for a liquid variable (or whatever it calls them). Annoyingly, unset variables are simply ignored or "".

vidhill commented 1 year ago

Ah, glad you got sorted