2020-11-04 17:46:19 +01:00
|
|
|
{{ $targetFilename := "file" }}
|
|
|
|
{{ if eq .type "css" }}
|
|
|
|
{{ $targetFilename = "css/style.css"}}
|
|
|
|
{{ else if eq .type "js" }}
|
|
|
|
{{ $targetFilename = "js/script.js"}}
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ $resource := resources.Get .filename }}
|
|
|
|
|
|
|
|
{{ if $resource }}
|
|
|
|
{{ $resource := $resource | resources.ExecuteAsTemplate $targetFilename . }}
|
2021-10-05 15:18:47 +02:00
|
|
|
{{ if hugo.IsProduction }}
|
2020-11-04 17:46:19 +01:00
|
|
|
{{ $resource = $resource | resources.Minify }}
|
|
|
|
{{ end }}
|
|
|
|
{{ $resource = $resource | resources.Fingerprint "sha256" }}
|
|
|
|
|
|
|
|
{{ if eq .type "css" }}
|
2024-04-09 13:33:28 +02:00
|
|
|
<link rel="stylesheet" href="{{ $resource.RelPermalink }}" integrity="{{ $resource.Data.Integrity }}">
|
2020-11-04 17:46:19 +01:00
|
|
|
{{ else if eq .type "js" }}
|
2024-04-09 13:33:28 +02:00
|
|
|
<script src="{{ $resource.RelPermalink }}" type="text/javascript" charset="utf-8" integrity="{{ $resource.Data.Integrity }}"></script>
|
2020-11-04 17:46:19 +01:00
|
|
|
{{ end }}
|
|
|
|
<!-- For backward compatibility -->
|
|
|
|
{{ else }}
|
|
|
|
{{ if eq .type "css" }}
|
|
|
|
<link rel="stylesheet" href="{{ .filename | absURL }}?rnd={{ now.Unix }}">
|
|
|
|
{{ else if eq .type "js" }}
|
|
|
|
<script src="{{ .filename | absURL }}?rnd={{ now.Unix }}" type="text/javascript" charset="utf-8"></script>
|
|
|
|
{{ end }}
|
2021-10-05 15:18:47 +02:00
|
|
|
{{ end }}
|