refactor!: rename assets origin configuration files

This commit is contained in:
Cotes Chung 2023-03-31 06:41:51 +08:00
parent 9d97120197
commit c283e7782f
No known key found for this signature in database
GPG key ID: 0D9E54843167A808
7 changed files with 33 additions and 33 deletions

View file

@ -58,15 +58,15 @@
{% include favicons.html %}
{% if site.resources.ignore_env != jekyll.environment and site.resources.self_hosted %}
<link href="{{ site.data.assets[origin].webfonts | relative_url }}" rel="stylesheet">
<link href="{{ site.data.origin[type].webfonts | relative_url }}" rel="stylesheet">
{% else %}
{% for cdn in site.data.assets[origin].cdns %}
{% for cdn in site.data.origin[type].cdns %}
<link rel="preconnect" href="{{ cdn.url }}" {{ cdn.args }}>
<link rel="dns-prefetch" href="{{ cdn.url }}" {{ cdn.args }}>
{% endfor %}
<link rel="stylesheet" href="{{ site.data.assets[origin].webfonts | relative_url }}">
<link rel="stylesheet" href="{{ site.data.origin[type].webfonts | relative_url }}">
{% endif %}
<!-- GA -->
@ -90,20 +90,20 @@
{% endif %}
<!-- Bootstrap -->
<link rel="stylesheet" href="{{ site.data.assets[origin].bootstrap.css | relative_url}}">
<link rel="stylesheet" href="{{ site.data.origin[type].bootstrap.css | relative_url}}">
<!-- Font Awesome -->
<link rel="stylesheet" href="{{ site.data.assets[origin].fontawesome.css | relative_url }}">
<link rel="stylesheet" href="{{ site.data.origin[type].fontawesome.css | relative_url }}">
<link rel="stylesheet" href="{{ '/assets/css/style.css' | relative_url }}">
{% if site.toc and page.toc %}
<link rel="stylesheet" href="{{ site.data.assets[origin].toc.css | relative_url }}">
<link rel="stylesheet" href="{{ site.data.origin[type].toc.css | relative_url }}">
{% endif %}
{% if page.layout == 'page' or page.layout == 'post' %}
<!-- Manific Popup -->
<link rel="stylesheet" href="{{ site.data.assets[origin].magnific-popup.css | relative_url }}">
<link rel="stylesheet" href="{{ site.data.origin[type].magnific-popup.css | relative_url }}">
{% endif %}
<!-- JavaScript -->
@ -113,5 +113,4 @@
{% endunless %}
{% include metadata-hook.html %}
</head>

View file

@ -2,11 +2,11 @@
<!-- commons -->
{% assign urls = site.data.assets[origin].jquery.js
{% assign urls = site.data.origin[type].jquery.js
| append: ','
| append: site.data.assets[origin].bootstrap.js
| append: site.data.origin[type].bootstrap.js
| append: ','
| append: site.data.assets[origin].search.js
| append: site.data.origin[type].search.js
%}
<!-- layout specified -->
@ -14,20 +14,20 @@
{% if page.layout == 'post' %}
{% if site.google_analytics.pv.proxy_endpoint or site.google_analytics.pv.cache_path %}
<!-- pv-report needs countup.js -->
{% assign urls = urls | append: ',' | append: site.data.assets[origin].countup.js %}
{% assign urls = urls | append: ',' | append: site.data.origin[type].countup.js %}
{% endif %}
{% endif %}
{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %}
{% assign urls = urls | append: ',' | append: site.data.assets[origin].lazysizes.js %}
{% assign urls = urls | append: ',' | append: site.data.origin[type].lazysizes.js %}
{% unless page.layout == 'home' %}
<!-- image lazy-loading & popup & clipboard -->
{% assign urls = urls
| append: ','
| append: site.data.assets[origin]['magnific-popup'].js
| append: site.data.origin[type]['magnific-popup'].js
| append: ','
| append: site.data.assets[origin].clipboard.js
| append: site.data.origin[type].clipboard.js
%}
{% endunless %}
{% endif %}
@ -42,37 +42,37 @@
{% assign urls = urls
| append: ','
| append: site.data.assets[origin].dayjs.js.common
| append: site.data.origin[type].dayjs.js.common
| append: ','
| append: site.data.assets[origin].dayjs.js.locale
| append: site.data.origin[type].dayjs.js.locale
| replace: ':LOCALE', locale
| append: ','
| append: site.data.assets[origin].dayjs.js.relativeTime
| append: site.data.origin[type].dayjs.js.relativeTime
| append: ','
| append: site.data.assets[origin].dayjs.js.localizedFormat
| append: site.data.origin[type].dayjs.js.localizedFormat
%}
{% endif %}
{% if page.content contains '<h2' or page.content contains '<h3' and site.toc and page.toc %}
{% assign urls = urls | append: ',' | append: site.data.assets[origin].toc.js %}
{% assign urls = urls | append: ',' | append: site.data.origin[type].toc.js %}
{% endif %}
{% if page.mermaid %}
{% assign urls = urls | append: ',' | append: site.data.assets[origin].mermaid.js %}
{% assign urls = urls | append: ',' | append: site.data.origin[type].mermaid.js %}
{% endif %}
{% include jsdelivr-combine.html urls=urls %}
{% case page.layout %}
{% when 'home', 'categories', 'post', 'page' %}
{% assign type = page.layout %}
{% assign js = page.layout %}
{% when 'archives', 'category', 'tag' %}
{% assign type = 'misc' %}
{% assign js = 'misc' %}
{% else %}
{% assign type = 'commons' %}
{% assign js = 'commons' %}
{% endcase %}
{% capture script %}/assets/js/dist/{{ type }}.min.js{% endcapture %}
{% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %}
<script defer src="{{ script | relative_url }}"></script>
{% if page.math %}
@ -94,8 +94,8 @@
}
};
</script>
<script src="{{ site.data.assets[origin].polyfill.js | relative_url }}"></script>
<script id="MathJax-script" async src="{{ site.data.assets[origin].mathjax.js | relative_url }}"></script>
<script src="{{ site.data.origin[type].polyfill.js | relative_url }}"></script>
<script id="MathJax-script" async src="{{ site.data.origin[type].mathjax.js | relative_url }}"></script>
{% endif %}
{% if jekyll.environment == 'production' %}

View file

@ -1,12 +1,13 @@
{% comment %} Site static assets origin {% endcomment %}
{% assign origin = 'cross_origin' %}
{% comment %} Site static assets origin type {% endcomment %}
{% assign type = 'cors' %}
{% if site.assets.self_host.enabled %}
{% if site.assets.self_host.env %}
{% if site.assets.self_host.env == jekyll.environment %}
{% assign origin = 'self_host' %}
{% assign type = 'basic' %}
{% endif %}
{% else %}
{% assign origin = 'self_host' %}
{% assign type = 'basic' %}
{% endif %}
{% endif %}

View file

@ -5,7 +5,7 @@ layout: compress
<!doctype html>
{% include assets-origin.html %}
{% include origin-type.html %}
{% include lang.html %}

View file

@ -3,7 +3,7 @@ layout: default
---
{% include lang.html %}
{% include assets-origin.html %}
{% include origin-type.html %}
<div class="row">
<!-- core -->