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

Support for gem theme assets #43

Open
kylekirkby opened this issue Dec 6, 2019 · 5 comments
Open

Support for gem theme assets #43

kylekirkby opened this issue Dec 6, 2019 · 5 comments

Comments

@kylekirkby
Copy link

kylekirkby commented Dec 6, 2019

Hi @janosrusiczki,

Thank you for the awesome asset pipeline! Any idea on what work is needed to fetch assets from a Jekyll theme? I'll happily submit a PR if you can point me in the right direction?

I thought Jekyll pulled assets over from the theme (see - https://jekyllrb.com/docs/themes/#understanding-gem-based-themes). Maybe the plugin is running before these have been synced over? Jekyll doesn't add the assets to the site directory but they must be referenced in Ruby array?

Kind regards,

Kyle

@janosrusiczki
Copy link
Owner

janosrusiczki commented Dec 6, 2019

As you can see from the documentation japr needs the assets that it compiles to be specified between Liquid tags like {% css_asset_tag global %} and {% endcss_asset_tag %} (and the same for javascript).

For example my own site / blog uses a post layout for the posts, which in turn use the default layout. The default layout includes a head file which contains:

{% css_asset_tag global %}
  - /_assets/poole.css
  - /_assets/syntax.css
  - /_assets/hyde.css
  - /_assets/jr.css
{% endcss_asset_tag %}

These css files will be then mashed together into one asset file during compilation.


The feature you are requesting is a very interesting one, and for it to work, from my point of view, it would require for japr to have sort of an automatic mode which would automagically gather local asset files from the layouts and then compile them together. Not sure how to implement it at this point though. 😄 I'll have to think about it.

@janosrusiczki
Copy link
Owner

janosrusiczki commented Dec 6, 2019

OR you could overwrite some of your theme's files as described here and insert the assets between {% xxx_asset_tag %}s. I'll have to test this out though.

@kylekirkby
Copy link
Author

Hi @janosrusiczki ,

I've got those bundles here:
https://github.com/linaro-marketing/linaro_simply_static_theme/tree/master/_includes/js_bundles

Currently I've got:

{% javascript_asset_tag vendor %}
- assets/js/vendor/modernizr.min.js
- node_modules/foundation-sites/dist/js/foundation.min.js
- assets/js/vendor/fastclick.js
- assets/js/vendor/featherlight.js
- assets/js/vendor/lazysizes.js
- assets/js/vendor/ls.unveilhooks.js
- assets/js/vendor/owl.carousel.js
- assets/js/vendor/what-input.min.js
- assets/js/vendor/clipboard.min.js
{% endjavascript_asset_tag %}
<script>
    $(document).foundation();
</script>

These assets are in the theme gem which you can see the location of with bundle show <theme-name> like:

kyle@gibson  ~/Documents/websites/linaro.org   implementing_new_jekyll_theme ● ? ⍟9  bundle show linaro_simply_static_theme  
/home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0

 kyle@gibson  ~/Documents/websites/linaro.org   implementing_new_jekyll_theme ● ? ⍟9  ls /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0 
assets  _config.yml  _data  _includes  _layouts  LICENSE.txt  README.md  _sass

I tried adding the full path to the theme assets with:

{% javascript_asset_tag vendor %}
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/modernizr.min.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/foundation.min.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/fastclick.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/featherlight.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/lazysizes.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/ls.unveilhooks.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/owl.carousel.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/what-input.min.js
- /home/kyle/.rvm/gems/ruby-2.5.2/gems/linaro_simply_static_theme-0.1.0/assets/js/vendor/clipboard.min.js
{% endjavascript_asset_tag %}
<script>
    $(document).foundation();
</script>

Which is all good other than japr only allows for asset paths relative to the project directory. Maybe we could grab the theme path in Ruby from Jekyll and combine those source directories with the local ones?

Many thanks for looking at this!

Cheers!

Kyle

@janosrusiczki
Copy link
Owner

Way ahead of me I see. 😄 I'll definitely look into it!

@janosrusiczki janosrusiczki changed the title Support for theme assets Support for gem theme assets Dec 6, 2019
@kylekirkby
Copy link
Author

Hahaha :D I'm just forking this repo and I'll have a quick poke around to see if I can do anything useful xD 💯

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

2 participants