All the template updates for fingerprinting

This commit is contained in:
Eryn Wells 2022-11-07 08:36:39 -08:00
parent 1751abadac
commit d0b223fa33
2 changed files with 31 additions and 39 deletions

View file

@ -13,40 +13,24 @@
{{ end }}
</body>
<style>
@font-face {
font-family: "Museo_Slab";
src: url("{{ `/fonts/Museo_Slab_500.woff2` | relURL }}") format("woff2"),
url("{{ `/fonts/Museo_Slab_500.woff` | relURL }}") format("woff");
font-weight: normal;
font-style: normal;
}
</style>
<link rel="stylesheet" as="style" href="{{ `/styles/root.css` | relURL }}">
{{- if not hugo.IsProduction -}}
<link rel="stylesheet" as="style" href="{{ `/styles/development.css` | relURL }}">
{{- end -}}
{{- $includedCSS := slice -}}
{{- if not .FirstSection.IsHome -}}
{{- range .FirstSection.Resources.Match "*.css" -}}
{{- if not (in $includedCSS .Permalink) -}}
{{- $includedCSS = $includedCSS | append .Permalink -}}
<link rel="stylesheet" as="style" href="{{ .RelPermalink }}">
{{- end -}}
{{- end -}}
{{- end -}}
{{- range .Resources.Match "*.css" -}}
{{- if not (in $includedCSS .Permalink) -}}
{{- $includedCSS = $includedCSS | append .Permalink -}}
<link rel="stylesheet" as="style" href="{{ .RelPermalink }}">
{{- end -}}
{{- end -}}
{{- $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 }}
{{ block "styles" . }}{{ end }}
{{ block "scripts" . }}{{ end }}
<script src="{{ `scripts/site.js` | relURL }}"></script>
{{ $concatenatedSiteScript := resources.Get "scripts/site.js"
| resources.Fingerprint "sha512" }}
<script type="module" src="{{ $concatenatedSiteScript.Permalink }}" integrity="{{ $concatenatedSiteScript.Data.Integrity }}"></script>
</html>

View file

@ -8,25 +8,33 @@
{{ define "styles" }}
{{- if .HasShortcode "figures/railroad" -}}
<link rel="preload stylesheet" as="style" href="{{ `styles/railroad.css` | absURL }}">
<link rel="preload stylesheet" as="style" href="{{ `styles/railroad.css` | absURL }}">
{{- end -}}
<link rel="preload stylesheet" as="style" href="{{ `styles/monokai.css` | absURL }}">
{{ end }}
{{ define "scripts" }}
{{- if .HasShortcode "figures/railroad" -}}
<script defer type="module" src="{{ `scripts/railroad.js` | absURL }}"></script>
<script defer type="module" src="{{ `scripts/railroad-utils.js` | absURL }}"></script>
{{- with partial "secure_asset.html" "scripts/lib/railroad.js" -}}
<script defer type="module" src="{{ .Secure.Permalink }}" integrity="{{ .Secure.Data.Integrity }}"></script>
{{- end -}}
{{- with resources.Get "scripts/railroad-utils.js" -}}
<script defer type="module" src="{{ .Secure.Permalink }}" integrity="{{ .Secure.Data.Integrity }}"></script>
{{- end -}}
{{- end -}}
{{- if .HasShortcode "figures/p5" -}}
<script defer src="{{ `scripts/p5-1.4.1.min.js` | absURL }}"></script>
<script defer src="{{ `scripts/sketch-utils.js` | absURL }}"></script>
{{- with partial "secure_asset.html" "scripts/lib/p5-1.5.0.js" -}}
<script defer src="{{ .Secure.Permalink }}" integrity="{{ .Secure.Data.Integrity }}"></script>
{{- end -}}
{{- with partial "secure_asset.html" "scripts/sketch-utils.js" -}}
<script defer src="{{ .Secure.Permalink }}" integrity="{{ .Secure.Data.Integrity }}"></script>
{{- end -}}
{{- end -}}
{{- range $script := .Resources.Match "*.js" -}}
{{- $isModule := default true $script.Params.is_module -}}
<script defer {{ if $isModule }}type="module"{{ end }} src="{{ $script.Permalink | relURL }}"></script>
{{- $isModule := default true $script.Params.is_module -}}
<script defer {{ if $isModule }}type="module"{{ end }} src="{{ $script.Permalink | relURL }}"></script>
{{- end -}}
{{ end }}