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

Allow changing Twig Namespaces #539

Closed
RobLoach opened this issue Jan 9, 2018 · 13 comments
Closed

Allow changing Twig Namespaces #539

RobLoach opened this issue Jan 9, 2018 · 13 comments
Assignees

Comments

@RobLoach
Copy link
Contributor

RobLoach commented Jan 9, 2018

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

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

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

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

thiagodemellobueno commented Mar 13, 2018

"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
Copy link
Contributor

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

thiagodemellobueno commented Mar 13, 2018

Also, @soniktrooth @RobLoach - this has always been possible, I added a namespace test to demonstrate:

Here's a PR #557

@soniktrooth
Copy link
Contributor

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

ABSOLUTE PATH

@soniktrooth
Copy link
Contributor

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

I also added this issue, which I hope to visit soon
#558

@thiagodemellobueno
Copy link
Contributor

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

soniktrooth commented Mar 13, 2018

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
Copy link
Contributor Author

🚀

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