web/_includes/js-selector.html

115 lines
3.3 KiB
HTML
Raw Permalink Normal View History

<!-- JS selector for site. -->
<!-- commons -->
2024-04-13 12:34:20 +03:00
<script src="/assets/js/user/copy.js"></script>
{% assign urls = site.data.origin[type].jquery.js
| append: ','
| append: site.data.origin[type].bootstrap.js
| append: ','
| append: site.data.origin[type].search.js
%}
2021-07-01 11:20:36 +03:00
<!-- layout specified -->
{% assign js_dist = '/assets/js/dist/' %}
{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %}
{% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %}
{% unless page.layout == 'home' %}
<!-- image lazy-loading & popup & clipboard -->
{% assign urls = urls
| append: ','
| append: site.data.origin[type]['magnific-popup'].js
| append: ','
| append: site.data.origin[type].clipboard.js
%}
{% endunless %}
2021-04-21 18:17:34 +03:00
{% endif %}
2021-01-23 10:07:18 +03:00
{% if page.layout == 'home'
or page.layout == 'post'
or page.layout == 'archives'
or page.layout == 'category'
or page.layout == 'tag'
%}
{% assign locale = site.lang | split: '-' | first %}
{% assign urls = urls
| append: ','
| append: site.data.origin[type].dayjs.js.common
| append: ','
| append: site.data.origin[type].dayjs.js.locale
| replace: ':LOCALE', locale
| append: ','
| append: site.data.origin[type].dayjs.js.relativeTime
| append: ','
| 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.origin[type].toc.js %}
{% endif %}
{% if page.mermaid %}
{% 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 js = page.layout %}
{% when 'archives', 'category', 'tag' %}
{% assign js = 'misc' %}
{% else %}
{% assign js = 'commons' %}
{% endcase %}
{% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %}
<script defer src="{{ script | relative_url }}"></script>
{% if page.math %}
<!-- MathJax -->
<script>
/* see: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options> */
MathJax = {
tex: {
/* start/end delimiter pairs for in-line math */
inlineMath: [
['$', '$'],
['\\(', '\\)']
],
/* start/end delimiter pairs for display math */
displayMath: [
['$$', '$$'],
['\\[', '\\]']
],
/* equation numbering */
tags: 'ams'
}
};
</script>
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="{{ site.data.origin[type].mathjax.js | relative_url }}"></script>
{% endif %}
2021-07-20 20:35:07 +03:00
{% if jekyll.environment == 'production' %}
<!-- PWA -->
{% if site.pwa.enabled %}
<script defer src="{{ 'app.min.js' | prepend: js_dist | relative_url }}"></script>
{% endif %}
2021-07-20 20:35:07 +03:00
<!-- GA -->
{% if site.google_analytics.id != empty and site.google_analytics.id %}
2021-07-20 20:35:07 +03:00
{% include google-analytics.html %}
{% endif %}
<!-- GoatCounter -->
{% if site.goatcounter.id != empty and site.goatcounter.id %}
{% include goatcounter.html %}
{% endif %}
2021-07-20 20:35:07 +03:00
{% endif %}