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

View file

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

View file

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

View file

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

View file

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