-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscripts.html
69 lines (56 loc) · 3.68 KB
/
scripts.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
{{ $array := slice }}
{{- if $.Site.Params.enableLazySyntaxHighlighting -}}
{{- /* These are copied from cdnjs but be sure to make the script loading to defer. */ -}}
{{- /* This could be automated somehow with cdnjs API and get the latest version of the library.
Then print the resulting script tag but I'm not too sure about getting the latest version would be good practice.
Still, it's a thing to ponder whether this should be implemented or not.
Take note this is possible with Hugo templates.
Hugo has a JSON parse function that can also fetch remote URLs so you can easily create dynamic content (e.g., GitHub repos and activities).
*/ -}}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-twilight.min.css" integrity="sha512-akb4nfKzpmhujLUyollw5waBPeohuVf0Z5+cL+4Ngc4Db+V8szzx6ZTujguFjpmD076W8LImVIbOblmQ+vZMKA==" crossorigin="anonymous" />
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js" integrity="sha512-YBk7HhgDZvBxmtOfUdvX0z8IH2d10Hp3aEygaMNhtF8fSOvBZ16D/1bXZTJV6ndk/L/DlXxYStP8jrF77v2MIg==" crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-zc7WDnCM3aom2EziyDIRAtQg1mVXLdILE09Bo+aE1xk0AM2c2cVLfSW9NrxE5tKTX44WBY0Z2HClZ05ur9vB6A==" crossorigin="anonymous"></script>
{{- end -}}
{{ if $.Site.Params.enableMathjax -}}
<!-- MathJax -->
<!-- Put your custom MathJax configuration over here. -->
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script>
window.addEventListener("load", function () {
const script = document.createElement("script");
script.src = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
script.async = true
document.head.appendChild(script);
})
</script>
{{- end -}}
{{- if $.Site.Params.enableContentImageZoom -}}
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/medium-zoom/1.0.6/medium-zoom.min.js" integrity="sha512-N9IJRoc3LaP3NDoiGkcPa4gG94kapGpaA5Zq9/Dr04uf5TbLFU5q0o8AbRhLKUUlp8QFS2u7S+Yti0U7QtuZvQ==" crossorigin="anonymous"></script>
{{- end -}}
<!-- The custom script -->
{{ $global := resources.Get "js/toggle-node.js" | minify }}
{{- $array = $array | append $global -}}
<!-- Site-wide search component -->
{{- if $.Site.Params.enableSiteSearch -}}
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.min.js"></script>
{{ $searchEngineSearchScript := resources.Get "js/search-post.js" | resources.ExecuteAsTemplate "js/_search.js" .| minify }}
{{ $array = $array | append $searchEngineSearchScript }}
{{- end -}}
<!-- Linking the resulting custom script -->
{{ $script := $array | resources.Concat "js/script.js" }}
{{ if (ne hugo.Environment "development")}}{{ $script = $script | resources.Fingerprint "sha512" }}{{ end }}
<script defer type="text/javascript" src="{{ $script.Permalink }}" {{ with $script.Data.Integrity }}integrity="{{ . }}"{{ end }}></script>
<!-- Site-wide user-included libraries -->
{{ with $.Site.Data.libraries }}
{{ $libraries := (sort . "weight" "asc") }}
{{ range $libraries }}
{{ if (eq .type "js") }}
<script type="{{ .type | default "text/javascript" }}" src="{{ .url }}" {{ if .defer }}defer{{ else if (not .sync) }}async{{ end }}></script>
{{ else if (eq .type "css") }}
<link rel="{{ .type | default "stylesheet" }}" href="{{ .url }}" />
{{ end }}
{{ end }}
<!-- If you're modifying to add your own thing, I recommend to start here. -->
<!-- Otherwise, you do you. :) -->
{{- template "_internal/google_analytics.html" . -}}
{{- end -}}