From 7f9817200b0e46dc3aca63a7a31de82b6d105e2f Mon Sep 17 00:00:00 2001 From: tdro Date: Fri, 6 May 2022 08:16:20 -0400 Subject: themes/default/layouts/partials/head: Bundle Fingerprint and cache bust automatically. --- .gitignore | 1 + Makefile | 7 +++++++ config.json | 3 ++- config.toml | 3 ++- config.yaml | 3 ++- themes/default/layouts/partials/csp.html | 8 ++++---- themes/default/layouts/partials/head.html | 17 ++++++++++++++--- 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4077f0f..6488bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ icons public resources +assets diff --git a/Makefile b/Makefile index 99aef3d..d428258 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ all: make config make js + make css make hugo config: @@ -12,6 +13,12 @@ watch: js: deno bundle --no-check --config tsconfig.json static/js/index.ts static/js/index.js + mkdir -p assets/js + cp static/js/index.js assets/js + +css: + mkdir -p assets/css + cp static/css/* assets/css hugo: rm -rf public diff --git a/config.json b/config.json index 357c47b..dfe7dce 100644 --- a/config.json +++ b/config.json @@ -83,7 +83,7 @@ } }, "params": { - "production": false, + "production": true, "webmanifest": { "name": "Micro Blog", "shortName": "Micro", @@ -93,6 +93,7 @@ "logo": "images/logo.png" }, "csp": { + "upgrade": false, "referrer": "origin", "childsrc": [ "'self'" diff --git a/config.toml b/config.toml index 676c81e..eaffbb7 100644 --- a/config.toml +++ b/config.toml @@ -80,7 +80,7 @@ enableRobotsTXT = true noHl = false [params] - production = false + production = true [params.webmanifest] name = "Micro Blog" @@ -91,6 +91,7 @@ enableRobotsTXT = true logo = "images/logo.png" [params.csp] + upgrade = false referrer = "origin" childsrc = ["'self'"] fontsrc = ["'self'"] diff --git a/config.yaml b/config.yaml index 5842f8f..5645336 100644 --- a/config.yaml +++ b/config.yaml @@ -67,7 +67,7 @@ markup: noHl: false params: - production: false + production: true webmanifest: name: Micro Blog shortName: Micro @@ -76,6 +76,7 @@ params: display: standalone logo: images/logo.png csp: + upgrade: false referrer: origin childsrc: ["'self'"] fontsrc: ["'self'"] diff --git a/themes/default/layouts/partials/csp.html b/themes/default/layouts/partials/csp.html index 62489ec..d148498 100644 --- a/themes/default/layouts/partials/csp.html +++ b/themes/default/layouts/partials/csp.html @@ -1,8 +1,8 @@ -{{ $upgrade := "" }} +{{- $upgrade := "" -}} -{{ if .Site.Params.production }} - {{ $upgrade = "upgrade-insecure-requests" }} -{{ end }} +{{- if .Site.Params.csp.upgrade -}} + {{ $upgrade = "upgrade-insecure-requests;" }} +{{- end -}} diff --git a/themes/default/layouts/partials/head.html b/themes/default/layouts/partials/head.html index e45b5d6..fd04ed0 100644 --- a/themes/default/layouts/partials/head.html +++ b/themes/default/layouts/partials/head.html @@ -35,13 +35,24 @@ {{- partial "csp.html" . -}} - + +{{- if .Site.Params.production -}} + +{{- $default := resources.Get "css/default.css" -}} +{{- $syntax := resources.Get "css/syntax-highlight-default.css" -}} +{{ $css := slice $default $syntax | resources.Concat "css/bundle.css" | resources.Minify | fingerprint }} + +{{ $js := resources.Get "js/index.js" | resources.Minify | fingerprint }} + + +{{ else }} + - - +{{- end -}} +