Get all the fingerprinting done!

- Add partials in the resources folder for each of the major resources of my site
- Consolidate .css and .js files via resources.Concat where possible
This commit is contained in:
Eryn Wells 2022-11-08 17:45:38 -08:00
parent d0b223fa33
commit 294fa8343b
14 changed files with 58 additions and 39 deletions

View file

@ -3,34 +3,30 @@
{{ partial "head.html" . }}
<body>
{{ block "body" . }}
{{ block "body" . -}}
{{ block "header" . }}{{ end }}
<main class="{{ .Type }} {{ .Kind }}{{ if gt (len .Pages) 0 }} list{{ end }}">
{{ block "main" . }}{{ end }}
</main>
{{ partial "development/page_info.html" . }}
{{ block "footer" . }}{{ end }}
{{ end }}
{{- partial "development/page_info.html" . -}}
{{- block "footer" . -}}{{- end -}}
{{- end -}}
</body>
{{- $rootCSS := resources.Get "styles/root.css"
| resources.ExecuteAsTemplate "root.css" .
| resources.Fingerprint "sha512" -}}
<link rel="stylesheet" as="style" href="{{ $rootCSS.RelPermalink }}" integrity="{{ $rootCSS.Data.Integrity }}">
{{ if not hugo.IsProduction }}
<link rel="stylesheet" as="style" href="{{ `/styles/development.css` | relURL }}">
{{ end }}
{{ with partial "secure_asset.html" (printf "styles/%s.css" .Section) }}
<link rel="stylesheet" as="style" href="{{ .Secure.RelPermalink }}" integrity="{{ .Secure.Data.Integrity }}">
{{ end }}
{{ range .Resources.Match "*.css" }}
<link rel="stylesheet" as="style" href="{{ .RelPermalink }}">
{{ end }}
{{ with partial "resources/root_css.html" . -}}
<link rel="stylesheet" as="style" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}">
{{- end -}}
{{- with partial "resources/section_css.html" . -}}
<link rel="stylesheet" as="style" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}">
{{- end -}}
{{- with partial "resources/page_css.html" . -}}
<link rel="stylesheet" as="style" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}">
{{- end -}}
{{ block "styles" . }}{{ end }}
{{ block "scripts" . }}{{ end }}
{{ $concatenatedSiteScript := resources.Get "scripts/site.js"
| resources.Fingerprint "sha512" }}
<script type="module" src="{{ $concatenatedSiteScript.Permalink }}" integrity="{{ $concatenatedSiteScript.Data.Integrity }}"></script>
{{- with partial "resources/site_js.html" . -}}
<script type="module" src="{{ .Permalink }}" integrity="{{ .Data.Integrity }}"></script>
{{ end }}
</html>