Closed marcinkrzeminski closed 5 years ago
Hey @marcinkrzeminski, the collection.js
should be inside scripts/templates
so you have scripts/templates/collection.js
. Then after that run yarn start
and it should work when on the collection template.
Hey @dan-gamble,
thanks for your reply. I just edited my original post, and I do have it in src/scripts/templates/
but it's still not working. Did you miss the src
within the path intentionally? On my installation Slate keeps all the files inside the src
directory so I think I shouldn't create anything outside having in mind that for example the src/sripts/templates/product.js
works fine.
The src
missing was intentional yes, i probably should have included it.
Could you show me what your dist/snippets/script-tags.liquid
looks like?
Hey again,
I checked the dist/snippets/script-tags.liquid
and the collection if statement is in place and I can see the collection related JS working now. That's super weird. I had other issues with Slate in the meantime so I've reinstalled all the npm packages as well as did the OS restart. Seems like this kind of fix never gets old 🤦♂️. Thanks for your time Dan.
No worries @marcinkrzeminski, glad you got it sorted :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Problem
Following the docs, I have created a collection.js file within the
src/scripts/templates/
directory. Unfortunately, the filetemplate.collection.js
is not created / loaded. I do have thesrc/templates/collection.liquid
file in my project. I also tried to start and stop the yarn watch process without any luck. As a temporary fix, I moved my collection dedicated code into the theme.js but I guess this is not the way to do it if I have a collection dedicated JS code.Replication steps
collection.js
within your `src/scripts/ directory and simply put console.log(1) for testingyarn watch
More Information
I run
yarn deploy
to create the file and deploy it but it's not loaded. I don't see it in the Network tab nor the code seems to be executed.My Setup:
node version 8.12.0 yarn version 1.12.1