-
Notifications
You must be signed in to change notification settings - Fork 2
/
js-selector.html
124 lines (107 loc) · 3.87 KB
/
js-selector.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!-- JS selector for site. -->
<!-- commons -->
{% assign urls = site.data.origin[type].jquery.js
| append: ','
| append: site.data.origin[type].bootstrap.js
| append: ','
| 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.origin[type].countup.js %}
{% endif %}
{% endif %}
{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home'
or page.layout == 'updates' %}
{% 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.origin[type]['magnific-popup'].js
| append: ','
| append: site.data.origin[type].clipboard.js
%}
{% endunless %}
{% endif %}
{% if page.layout == 'home'
or page.layout == 'post'
or page.layout == 'archives'
or page.layout == 'category'
or page.layout == 'tag'
or page.layout == 'updates'
%}
{% 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', 'lab_life' %}
{% assign js = page.layout %}
{% when 'archives', 'category', 'tag' %}
{% assign js = 'misc' %}
{% when 'updates' %}
{% assign js = 'home' %}
{% else %}
{% assign js = 'commons' %}
{% endcase %}
{% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %}
<script defer src="{{ script | relative_url }}"></script>
<script src="https://cdn.jsdelivr.net/npm/masonry-layout@4.2.2/dist/masonry.pkgd.min.js" integrity="sha384-GNFwBvfVxBkLMJpYMOABq3c+d3KnQxudP/mGPkzpZSTYykLBNsZEnG2D9G/X/+7D" crossorigin="anonymous"></script>
<script src="https://unpkg.com/imagesloaded@5/imagesloaded.pkgd.min.js"></script>
{% if page.layout == 'lab_life' %}
<script src="/assets/lib/splide/splide.min.js"></script>
<link href="/assets/lib/splide/splide.min.css" rel="stylesheet">
{% endif %}
{% 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: [
['$$', '$$'],
['\\[', '\\]']
]
}
};
</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' %}
<!-- PWA -->
{% if site.pwa.enabled %}
<script defer src="{{ '/app.js' | relative_url }}"></script>
{% else %}
<script defer src="{{ '/unregister.js' | relative_url }}"></script>
{% endif %}
<!-- GA -->
{% if site.google_analytics.id != empty and site.google_analytics.id %}
{% include google-analytics.html %}
{% endif %}
{% endif %}