Revise Sweetalert asset load

Use Hugo Pipes to load the Sweetalert script when needed.
This commit is contained in:
Tim Bannister 2024-08-13 23:56:59 +01:00
parent 5a283be787
commit 93bd8323cc
2 changed files with 7 additions and 1 deletions

View File

@ -6,7 +6,13 @@
{{ end }}
{{/* copy-and-paste helper for codenew shortcode */}}
{{- if or (.HasShortcode "code_sample") (.HasShortcode "code") (.HasShortcode "codenew") -}}
<script async src="{{ "js/sweetalert-2.1.2.min.js" | relURL }}"></script>
{{- if hugo.IsProduction -}}
{{- $sweetAlert := resources.Get "js/sweetalert-2.1.2.min.js" | minify | fingerprint -}}
<script async src="{{ $sweetAlert.RelPermalink }}" integrity="{{ $sweetAlert.Data.Integrity }}" crossorigin="anonymous"></script>
{{- else -}}
{{- $sweetAlert := resources.Get "js/sweetalert-2.1.2.min.js" -}}
<script async src="{{ $sweetAlert.RelPermalink }}"></script>
{{- end -}}
<script type="text/javascript">
function copyCode(elem){
if (document.getElementById(elem)) {