Closed RobLoach closed 1 year ago
This is starting to jam things up on SJWC. @RobLoach or @thiagodemellobueno it would be great to knock this one over if either of you have time. 🍻
Friendly ping. This is always going to be a problem if we want a convenient solution for using svg icons. Anything I can do to help @RobLoach or @thiagodemellobueno ?
@soniktrooth
I think this issue is easily resolved by linking to svgs using /images/foo/bar.svg
So though its nice to have a namespace, we did all this work to make sure the site root was somewhere constant in relation to where twig is running from.
I was able to remove the warnings from SJWC this way.
"Just write it out" An icon namespace would be a nice convenience, but it is in no way a blocker.
And theres no clear solution so long as we cant pass things over to KSS.
@soniktrooth @RobLoach - I also think it makes more sense to use kalastatic's assets bit to move the files to where we keep all our assets, than wait for an upstream fix on the KSS side which isnt coming anytime soon.
Also, @soniktrooth @RobLoach - this has always been possible, I added a namespace test to demonstrate:
Here's a PR https://github.com/kalamuna/kalastatic/pull/557
@thiagodemellobueno I think this issue description was a bit misleading—I knew it was possible on the metalsmith side, it's the KSS side that was the issue. Are you suggesting that it's not something we can get around until KSS itself changes?
ABSOLUTE PATH
@thiagodemellobueno
I now understand and do humbly offer my apologies for my misgivings in this matter. I hope you can see a way to forgive me for such a discourteous offence. I look forward to your reply.
Graciously, Joshua
I also added this issue, which I hope to visit soon https://github.com/kalamuna/kalastatic/issues/558
To document a temporary solution this works for me in the sjwater context.
{% include '../../../../../../../../node_modules/fontawesome-svg-twig/' ~ icon ~ '.svg.twig' %}
this gets cleaner when using custom icons we may put in components/icons/**/*
rather than a node dependency.
Ok, best solution for me—where I'm not using a node module to hold the icons—was to make a twig template that looked like this in the @atoms
folder:
<span class="icon" aria-hidden="true">
{% include '@kalastatic/components/icons/' ~ icon ~ '.svg.twig' %}
</span>
Then I can reference THAT template and pass it the name of the icon.
I think this is perfectly workable going forward.
:rocket:
https://github.com/kalamuna/kalastatic/blob/master/src/kalastatic.js#L152-L155
Allow custom namespace paths for https://github.com/kalamuna/fontawesome-svg-twig .