Implement fingerprinting site and page resources
This will keep browsers from caching files that have changed. I've also added SRI information to the <script> and <link> elements for browsers to verify resources. Squashed commit of the following: commitf3fcb16388
Author: Eryn Wells <eryn@erynwells.me> Date: Tue Nov 8 17:47:42 2022 -0800 Remove static/styles/root.css commit53a30624a0
Author: Eryn Wells <eryn@erynwells.me> Date: Tue Nov 8 17:47:26 2022 -0800 Add back the basic table styles that got ditched when root.css was moved to assets/styles commit294fa8343b
Author: Eryn Wells <eryn@erynwells.me> Date: Tue Nov 8 17:45:38 2022 -0800 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 commitd0b223fa33
Author: Eryn Wells <eryn@erynwells.me> Date: Mon Nov 7 08:36:39 2022 -0800 All the template updates for fingerprinting commit1751abadac
Author: Eryn Wells <eryn@erynwells.me> Date: Mon Nov 7 08:36:27 2022 -0800 Add secure_asset.html template commit94ea8068c9
Author: Eryn Wells <eryn@erynwells.me> Date: Mon Nov 7 08:35:48 2022 -0800 Move a bunch of scripts and CSS to assets so they can be processed with Hugo Pipes Use Pipes to fingerprint and add SLI information to <script> and <link> tags.
This commit is contained in:
parent
f8174ab27c
commit
9601e1e283
24 changed files with 106327 additions and 55 deletions
5
layouts/partials/resources/page_css.html
Normal file
5
layouts/partials/resources/page_css.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{ $pageCSS := dict }}
|
||||
{{ with .Resources.Match "*.css" }}
|
||||
{{ $pageCSS = . | resources.Concat "page.css" | fingerprint "sha512" }}
|
||||
{{ end }}
|
||||
{{ return $pageCSS }}
|
4
layouts/partials/resources/railroad_utils.html
Normal file
4
layouts/partials/resources/railroad_utils.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
{{- $railroadUtilsJS := resources.Get "scripts/railroad-utils.js"
|
||||
| resources.ExecuteAsTemplate "scripts/railroad_utils.js" .
|
||||
| resources.Fingerprint "sha512" -}}
|
||||
{{ return $railroadUtilsJS }}
|
11
layouts/partials/resources/root_css.html
Normal file
11
layouts/partials/resources/root_css.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{ $allStylesheets := slice (resources.Get "styles/root.css")
|
||||
(resources.Get "styles/railroad.css")
|
||||
(resources.Get "styles/monokai.css") }}
|
||||
{{ if not hugo.IsProduction }}
|
||||
{{ $allStylesheets = $allStylesheets | append (resources.Get "styles/development.css") }}
|
||||
{{ end }}
|
||||
{{ $rootCSS := $allStylesheets
|
||||
| resources.Concat "styles/root.css"
|
||||
| resources.ExecuteAsTemplate "styles/root.css" .
|
||||
| fingerprint "sha512" }}
|
||||
{{ return $rootCSS }}
|
11
layouts/partials/resources/section_css.html
Normal file
11
layouts/partials/resources/section_css.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{ $sectionCSS := dict }}
|
||||
{{ $sectionStylesheet := "" }}
|
||||
{{ if .IsHome }}
|
||||
{{ $sectionStylesheet = printf "styles/home.css" }}
|
||||
{{ else }}
|
||||
{{ $sectionStylesheet = printf "styles/%s.css" .Section }}
|
||||
{{ end }}
|
||||
{{ with resources.Get $sectionStylesheet }}
|
||||
{{ $sectionCSS = . | fingerprint "sha512" }}
|
||||
{{ end }}
|
||||
{{ return $sectionCSS }}
|
2
layouts/partials/resources/site_js.html
Normal file
2
layouts/partials/resources/site_js.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
{{ $siteJS := resources.Get "scripts/site.js" | fingerprint "sha512" }}
|
||||
{{ return $siteJS }}
|
Loading…
Add table
Add a link
Reference in a new issue