Skip to content

Commit

Permalink
refactor!: rename assets origin configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed May 12, 2023
1 parent 9d97120 commit c283e77
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
File renamed without changes.
File renamed without changes.
15 changes: 7 additions & 8 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand All @@ -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 -->
Expand All @@ -113,5 +113,4 @@
{% endunless %}

{% include metadata-hook.html %}

</head>
38 changes: 19 additions & 19 deletions _includes/js-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

<!-- 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 -->

{% 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 %}
Expand All @@ -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 %}
Expand All @@ -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' %}
Expand Down
9 changes: 5 additions & 4 deletions _includes/assets-origin.html → _includes/origin-type.html
Original file line number Diff line number Diff line change
@@ -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 %}
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!doctype html>

{% include assets-origin.html %}
{% include origin-type.html %}

{% include lang.html %}

Expand Down
2 changes: 1 addition & 1 deletion _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---

{% include lang.html %}
{% include assets-origin.html %}
{% include origin-type.html %}

<div class="row">
<!-- core -->
Expand Down

0 comments on commit c283e77

Please sign in to comment.