Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Add @shopify/slate-snippets-plugin. #1015

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dan-gamble
Copy link
Contributor

What are you trying to accomplish with this PR?

I will preface this by saying this is super super bare bones at the moment. No tests, no README.md just the working source code. I'm just wanting to get a feel to see if this would be wanted, if so i'll add all the relevant pieces (as well as i can) otherwise i'll just using it locally extending my slate.config.js.

This is a plugin heavily influenced by the Sections Plugin.

It's a pretty simple plugin that adds the ability to have folders within the snippets folder like:

./snippets
├── collection/
   ├── filters.liquid
   ├── list.liquid
   ├── ...
├── product/
   ├── images.liquid
   ├── variants.liquid
   ├── ...

They get turned in to [folder-name]-[file-name].liquid on build.

./snippets
├── product/
   ├── images.liquid => product-images.liquid
   ├── variants.liquid => product-variants.liquid
   ├── ...

You can still use snippets as per normal not in folders.

Oustanding issues

I appreciate Slate is on Low Maintenance but any feedback on this would be highly appreciated. Even if it's just a +1 from anyone's Shopify's end to let me know to carry on and flesh this out 🤙

Please provide a link to the associated GitHub issue.
#781

Checklist

For contributors:

For maintainers:

  • I have 🎩'd these changes.

@cjayyy
Copy link

cjayyy commented Jul 2, 2019

Thanks a lot Dan.
This is very useful since Shopify can't come with official solution.

Have you somehow manage to delete/ignore original snippets subfolders ending in the dist?
I am trying to enhance your plugin with fs-extra.remove() but with no luck. If you have any solution please share :)

Thanks again <3

@dan-gamble
Copy link
Contributor Author

Hey @cjayyy,

I didn't find a solution for that, unfortunately.

Ultimately, we ended up dropping this internally as it was actually a bit of a pain to use (besides the duplicated files and errors).

For example when doing {% include 'product-carousel' %} with:

./snippets
├── product/
   ├── carousel.liquid
   ├── ...

It's actually slightly counter-intuitive when trying to find the file. When searching for product-carousel nothing is returned. There are also cases where you end up with quite a few duplicate file names which also makes it quite hard to navigate files properly.

./snippets
├── article/
   ├── carousel.liquid
   ├── ...
├── collection/
   ├── carousel.liquid
   ├── ...
├── product/
   ├── carousel.liquid
   ├── ...

Happy for someone else to pick this up, and I can help contribute to that, but it's not something I will actively be continuing with, unfortunately.

@cjayyy
Copy link

cjayyy commented Jul 25, 2019

Thanks for the response @dan-gamble!

So you adapted to the original Slate structure and you have all the snippets on one level or you found out another way?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants