generate an app.cache with Jekyll
Asked Answered
A

2

11

We have a site that builds locally with Jekyll and Jekyll-Assets (which uses sprockets).

We'd like to be able to generate a cache manifest that has all the files that go into the resultant site. We'd like to generate this as a part of the build process so that the entire site will be available offline. (It's a very small site, but we're opposed to manual work!)

The images and the css have a hash appended to the filename during the build so we can't predict the outcome.

We've tried using the {% asset_path logo.png %} etc. method, but it doesn't get processed. I.e. it leaves the Liquid tag as is in the final file. ERB does work (<%= 2+3 %> gives 5) but we can't see a way of accessing the resultant files.

We are considering another task runner to wrap the whole thing, but this feels like overkill.

Abroad answered 5/5, 2015 at 8:30 Comment(1)
Can you post the contents of your page with the liquid that didn't work?Missis
L
7

jekyll-perf builds a manifest.appcache file. The project appears as if it might be dormant, but they were doing it as follows. Hopefully this is useful as a starting point. You may need to adjust things for your asset paths etc., naturally.

(I'm not sure if the for stuff in this will take care of your appended hash issue or not. Apologies if this is exactly what you've already tried and it hasn't worked for you.)

---
---
CACHE MANIFEST

# rev {{ site.buildtime }}

CACHE:
{% asset_path all.css %}
{% for page in site.pages %}{% if page.url != '/manifest.appcache' %}{{ page.url }}{% endif %}
{% endfor %}
{% for item in site.images %}{{ item.url }}
{% endfor %}
{% for item in site.scripts %}{{ item.url }}
{% endfor %}

NETWORK:
*
http://*
https://*
Lansquenet answered 13/5, 2015 at 5:43 Comment(0)
L
3

Don't forget :

  • The empty front matter in your manifest

    ---
    # empty front matter
    ---
    [...]
    
  • To loop over your collections if your outputting them.

Lemmy answered 19/5, 2015 at 21:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.