1+ <!-- Google tag (gtag.js) -->
2+ < script async src ="https://www.googletagmanager.com/gtag/js?id=G-7SM0DFG7FG "> </ script >
3+ < script >
4+ window . dataLayer = window . dataLayer || [ ] ;
5+ function gtag ( ) { dataLayer . push ( arguments ) ; }
6+ gtag ( 'js' , new Date ( ) ) ;
7+ gtag ( 'config' , 'G-7SM0DFG7FG' ) ;
8+ </ script >
9+
10+ {{- with resources.Get "js/main.js" }}
11+ {{- $opts := dict
12+ "minify" (not hugo.IsDevelopment)
13+ "sourceMap" (cond hugo.IsDevelopment "external" "")
14+ "targetPath" "js/main.js"
15+ }}
16+ {{- with . | js.Build $opts }}
17+ {{- if hugo.IsDevelopment }}
18+ < script src ="{{ .RelPermalink }} "> </ script >
19+ {{- else }}
20+ {{- with . | fingerprint }}
21+ < script
22+ src ="{{ .RelPermalink }} "
23+ integrity ="{{ .Data.Integrity }} "
24+ crossorigin ="anonymous "> </ script >
25+ {{- end }}
26+ {{- end }}
27+ {{- end }}
28+ {{- end }}
29+
30+
31+ <!-- Gumshoe 库 - 只在文章页面加载 -->
32+ {{- if .IsPage }}
33+ < script src ="{{ "js /gumshoe.polyfills.min.js" | relURL }}"> </ script >
34+ {{- end }}
35+
36+
37+ <!-- 目录功能脚本 - 只在文章页面加载,需要在 dock.js 之前加载 -->
38+ {{- if .IsPage }}
39+ {{- with resources.Get "js/toc.js" }}
40+ {{- $opts := dict
41+ "minify" (not hugo.IsDevelopment)
42+ "sourceMap" (cond hugo.IsDevelopment "external" "")
43+ "targetPath" "js/toc.js"
44+ }}
45+ {{- with . | js.Build $opts }}
46+ {{- if hugo.IsDevelopment }}
47+ < script src ="{{ .RelPermalink }} " defer > </ script >
48+ {{- else }}
49+ {{- with . | fingerprint }}
50+ < script
51+ src ="{{ .RelPermalink }} "
52+ integrity ="{{ .Data.Integrity }} "
53+ crossorigin ="anonymous "
54+ defer > </ script >
55+ {{- end }}
56+ {{- end }}
57+ {{- end }}
58+ {{- end }}
59+ {{- end }}
60+
61+
62+ <!-- 搜索功能脚本 -->
63+ {{- with resources.Get "js/search.js" }}
64+ {{- $opts := dict
65+ "minify" (not hugo.IsDevelopment)
66+ "sourceMap" (cond hugo.IsDevelopment "external" "")
67+ "targetPath" "js/search.js"
68+ }}
69+ {{- with . | js.Build $opts }}
70+ {{- if hugo.IsDevelopment }}
71+ < script src ="{{ .RelPermalink }} " defer > </ script >
72+ {{- else }}
73+ {{- with . | fingerprint }}
74+ < script
75+ src ="{{ .RelPermalink }} "
76+ integrity ="{{ .Data.Integrity }} "
77+ crossorigin ="anonymous "
78+ defer > </ script >
79+ {{- end }}
80+ {{- end }}
81+ {{- end }}
82+ {{- end }}
83+
84+
85+ <!-- Dock 控制脚本 -->
86+ {{- with resources.Get "js/dock.js" }}
87+ {{- $opts := dict
88+ "minify" (not hugo.IsDevelopment)
89+ "sourceMap" (cond hugo.IsDevelopment "external" "")
90+ "targetPath" "js/dock.js"
91+ }}
92+ {{- with . | js.Build $opts }}
93+ {{- if hugo.IsDevelopment }}
94+ < script src ="{{ .RelPermalink }} " defer > </ script >
95+ {{- else }}
96+ {{- with . | fingerprint }}
97+ < script
98+ src ="{{ .RelPermalink }} "
99+ integrity ="{{ .Data.Integrity }} "
100+ crossorigin ="anonymous "
101+ defer > </ script >
102+ {{- end }}
103+ {{- end }}
104+ {{- end }}
105+ {{- end }}
106+
107+
108+ {{/* FJ Gallery */}}
109+ {{/* Gallery JavaScript */}}
110+ {{ if .Scratch.Get "justifiedEnabled" }}
111+ < script src ="/js/fjGallery.min.js "> </ script >
112+ {{ end }}
113+
114+ {{ if .Scratch.Get "lightboxEnabled" }}
115+ < script src ="/js/glightbox.min.js "> </ script >
116+ {{ end }}
117+
118+ {{/* 检测 masonry 短代码 */}}
119+ {{ $hasMasonryShortcode := false }}
120+ {{ if .RawContent }}
121+ {{ if findRE `{{< \s*masonry` .RawContent }}
122+ {{ $hasMasonryShortcode = true }}
123+ {{ end }}
124+ {{ end }}
125+
126+ {{ if $hasMasonryShortcode }}
127+ < script src ="/js/macy.js "> </ script >
128+ {{ if not (.Scratch.Get "lightboxEnabled") }}
129+ {{ $globalLightbox := site.Params.lightbox | default dict }}
130+ {{ $lightboxEnabled := $globalLightbox.enabled | default false }}
131+ {{ if not $lightboxEnabled }}
132+ < script src ="/js/glightbox.min.js "> </ script >
133+ {{ end }}
134+ {{ end }}
135+ {{ end }}
136+
137+
138+ {{ if or (.Scratch.Get "justifiedEnabled") (.Scratch.Get "lightboxEnabled") }}
139+ {{- with resources.Get "js/gallery.js" }}
140+ {{- $opts := dict
141+ "minify" (not hugo.IsDevelopment)
142+ "sourceMap" (cond hugo.IsDevelopment "external" "")
143+ "targetPath" "js/gallery.js"
144+ }}
145+ {{- with . | js.Build $opts }}
146+ {{- if hugo.IsDevelopment }}
147+ < script src ="{{ .RelPermalink }} " defer > </ script >
148+ {{- else }}
149+ {{- with . | fingerprint }}
150+ < script
151+ src ="{{ .RelPermalink }} "
152+ integrity ="{{ .Data.Integrity }} "
153+ crossorigin ="anonymous "
154+ defer > </ script >
155+ {{- end }}
156+ {{- end }}
157+ {{- end }}
158+ {{- end }}
159+ {{ end }}
160+
161+
162+
163+ <!-- 自定义 JS 文件 -->
164+ {{- $customJsFiles := resources.Match "js/custom/*.js" }}
165+ {{- range $customJsFiles }}
166+ {{- $fileName := .Name }}
167+ {{- $targetPath := printf "js/custom/%s" $fileName }}
168+ {{- $opts := dict
169+ "minify" (not hugo.IsDevelopment)
170+ "sourceMap" (cond hugo.IsDevelopment "external" "")
171+ "targetPath" $targetPath
172+ }}
173+ {{- with . | js.Build $opts }}
174+ {{- if hugo.IsDevelopment }}
175+ < script src ="{{ .RelPermalink }} " defer > </ script >
176+ {{- else }}
177+ {{- with . | fingerprint }}
178+ < script
179+ src ="{{ .RelPermalink }} "
180+ integrity ="{{ .Data.Integrity }} "
181+ crossorigin ="anonymous "
182+ defer > </ script >
183+ {{- end }}
184+ {{- end }}
185+ {{- end }}
186+ {{- end }}
187+
188+
189+ {{ if .Site.Params.analytics.enabled -}}
190+ {{ partial "features/analytics.html" . }}
191+ {{- end }}
0 commit comments