kalamuna / kalastatic

:electric_plug: Facilitate the front-end experience through Styleguides and Prototypes
https://kalamuna.github.io/kalastatic/
41 stars 14 forks source link

Allow changing Twig Namespaces #539

Closed RobLoach closed 1 year ago

RobLoach commented 6 years ago

https://github.com/kalamuna/kalastatic/blob/master/src/kalastatic.js#L152-L155

Allow custom namespace paths for https://github.com/kalamuna/fontawesome-svg-twig .

namespaces:
  icons: node_modules/fontawesome-svg-twig
include "@icons/solid/stuff.svg.twig"
soniktrooth commented 6 years 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. 🍻

soniktrooth commented 6 years ago

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 ?

thiagodemellobueno commented 6 years ago

@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.

thiagodemellobueno commented 6 years ago

"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.

thiagodemellobueno commented 6 years ago

@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.

thiagodemellobueno commented 6 years ago

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

soniktrooth commented 6 years ago

@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?

thiagodemellobueno commented 6 years ago

ABSOLUTE PATH

soniktrooth commented 6 years ago

@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

thiagodemellobueno commented 6 years ago

I also added this issue, which I hope to visit soon https://github.com/kalamuna/kalastatic/issues/558

thiagodemellobueno commented 6 years ago

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.

soniktrooth commented 6 years ago

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.

RobLoach commented 1 year ago

:rocket: