37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
---
|
|
layout: nil
|
|
---
|
|
var urlsToCache = [];
|
|
|
|
var CACHE_NAME = 'Setto-cache-v1';
|
|
|
|
// Cache posts
|
|
// Limits the number of posts that gets cached to 3
|
|
// Reads a piece of front-matter in each post that directs the second loop to the folder where the assets are held
|
|
{% for post in site.posts %}
|
|
urlsToCache.push("{{ post.url }}index.html")
|
|
{% endfor %}
|
|
|
|
// Cache pages
|
|
// Do nothing if it's either an AMP page (as these are served via Googles cache) or the blog page
|
|
// Fallback to the offline pages for these
|
|
{% for page in site.html_pages %}{% unless page.sitemap == false %}
|
|
urlsToCache.push("{{ page.url }}index.html")
|
|
{% endunless %}{% endfor %}
|
|
|
|
// Cache assets
|
|
// Removed assets/posts because I only want assets from the most recent posts getting cached
|
|
{% for file in site.static_files %}{% unless file.path contains 'albums' %}
|
|
urlsToCache.push("{{ file.path }}")
|
|
{% endunless %}{% endfor %}
|
|
|
|
|
|
|
|
// Cache mp3 and cover art
|
|
{% for track in site.tracks %}
|
|
urlsToCache.push("{{ track.url }}")
|
|
urlsToCache.push("{{ site.mediaurl }}/{{ track.slug }}.mp3")
|
|
urlsToCache.push("{{ site.mediaurl }}/{{ track.slug }}.jpeg")
|
|
{% endfor %}
|
|
|