mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 05:41:31 +00:00
Make the source of the static assets configurable
- Easy to switch between different CDN - Allow self-host static assets
This commit is contained in:
32
_includes/jsdelivr-combine.html
Normal file
32
_includes/jsdelivr-combine.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% assign urls = include.urls | split: ',' %}
|
||||
|
||||
{% assign combined_urls = nil %}
|
||||
|
||||
{% assign domain = 'https://cdn.jsdelivr.net/' %}
|
||||
|
||||
{% for url in urls %}
|
||||
|
||||
{% if url contains domain %}
|
||||
{% assign url_snippet = url | slice: domain.size, url.size %}
|
||||
|
||||
{% if combined_urls %}
|
||||
{% assign combined_urls = combined_urls | append: ',' | append: url_snippet %}
|
||||
{% else %}
|
||||
{% assign combined_urls = domain | append: 'combine/' | append: url_snippet %}
|
||||
{% endif %}
|
||||
|
||||
{% elsif url contains '//' %}
|
||||
|
||||
<script src="{{ url }}"></script>
|
||||
|
||||
{% else %}
|
||||
|
||||
<script src="{{ url | relative_url }}"></script>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% if combined_urls %}
|
||||
<script src="{{ combined_urls }}"></script>
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user