Skip to content

Commit 93bd832

Browse files
author
Tim Bannister
committed
Revise Sweetalert asset load
Use Hugo Pipes to load the Sweetalert script when needed.
1 parent 5a283be commit 93bd832

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
File renamed without changes.

layouts/partials/hooks/body-end.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
{{ end }}
77
{{/* copy-and-paste helper for codenew shortcode */}}
88
{{- if or (.HasShortcode "code_sample") (.HasShortcode "code") (.HasShortcode "codenew") -}}
9-
<script async src="{{ "js/sweetalert-2.1.2.min.js" | relURL }}"></script>
9+
{{- if hugo.IsProduction -}}
10+
{{- $sweetAlert := resources.Get "js/sweetalert-2.1.2.min.js" | minify | fingerprint -}}
11+
<script async src="{{ $sweetAlert.RelPermalink }}" integrity="{{ $sweetAlert.Data.Integrity }}" crossorigin="anonymous"></script>
12+
{{- else -}}
13+
{{- $sweetAlert := resources.Get "js/sweetalert-2.1.2.min.js" -}}
14+
<script async src="{{ $sweetAlert.RelPermalink }}"></script>
15+
{{- end -}}
1016
<script type="text/javascript">
1117
function copyCode(elem){
1218
if (document.getElementById(elem)) {

0 commit comments

Comments
 (0)