From b1790c777663f1703c760f8c968d0bc3d3dea193 Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Sun, 3 Oct 2021 10:42:07 -0700 Subject: [PATCH] Added hash to resource filenames Cache busting is here wooooo --- .pre-commit-config.yaml | 3 ++ .prettierrc | 10 ++++++ .prettierrc.json | 1 - package.json | 3 +- .../{static => assets}/css/highlight.css | 0 .../css/style.css => assets/css/main.css} | 0 .../{static => assets}/js/keynav.js | 0 .../layouts/partials/footer.html | 5 ++- .../layouts/partials/head.html | 31 ++++++++++++++----- yarn.lock | 21 +++++++++++++ 10 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 .prettierrc delete mode 100644 .prettierrc.json rename themes/alejandro-angulo/{static => assets}/css/highlight.css (100%) rename themes/alejandro-angulo/{static/css/style.css => assets/css/main.css} (100%) rename themes/alejandro-angulo/{static => assets}/js/keynav.js (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b4d144d..dd74081 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,3 +21,6 @@ repos: rev: v2.4.1 hooks: - id: prettier + additional_dependencies: + - prettier@2.4.1 + - prettier-plugin-go-template@0.0.11 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c99d7d5 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "overrides": [ + { + "files": ["*.html"], + "options": { + "parser": "go-template" + } + } + ] +} diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 0967ef4..0000000 --- a/.prettierrc.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/package.json b/package.json index 4df3655..370ed98 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "packageManager": "yarn@3.0.2", "devDependencies": { "eslint": "^7.32.0", - "prettier": "^2.4.1" + "prettier": "^2.4.1", + "prettier-plugin-go-template": "^0.0.11" } } diff --git a/themes/alejandro-angulo/static/css/highlight.css b/themes/alejandro-angulo/assets/css/highlight.css similarity index 100% rename from themes/alejandro-angulo/static/css/highlight.css rename to themes/alejandro-angulo/assets/css/highlight.css diff --git a/themes/alejandro-angulo/static/css/style.css b/themes/alejandro-angulo/assets/css/main.css similarity index 100% rename from themes/alejandro-angulo/static/css/style.css rename to themes/alejandro-angulo/assets/css/main.css diff --git a/themes/alejandro-angulo/static/js/keynav.js b/themes/alejandro-angulo/assets/js/keynav.js similarity index 100% rename from themes/alejandro-angulo/static/js/keynav.js rename to themes/alejandro-angulo/assets/js/keynav.js diff --git a/themes/alejandro-angulo/layouts/partials/footer.html b/themes/alejandro-angulo/layouts/partials/footer.html index 0380a4c..0dbba71 100644 --- a/themes/alejandro-angulo/layouts/partials/footer.html +++ b/themes/alejandro-angulo/layouts/partials/footer.html @@ -1 +1,4 @@ - +{{ $keynav := resources.Get "js/keynav.js" | minify | fingerprint }} diff --git a/themes/alejandro-angulo/layouts/partials/head.html b/themes/alejandro-angulo/layouts/partials/head.html index 978af26..313d4d7 100644 --- a/themes/alejandro-angulo/layouts/partials/head.html +++ b/themes/alejandro-angulo/layouts/partials/head.html @@ -1,10 +1,25 @@ - - - - - - {{ $title := print .Site.Title " | " .Title }} - {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }} - {{ $title }} + + + + {{ $main_style := resources.Get "css/main.css" | minify }} + {{ $highlight_style := resources.Get "css/highlight.css" | minify }} + {{ $css := slice $main_style $highlight_style | resources.Concat "css/style.css" | fingerprint }} + + {{ $title := print .Site.Title " | " .Title }} + {{ if .IsHome }} + {{ $title = + .Site.Title + }} + {{ end }} + {{ $title }} diff --git a/yarn.lock b/yarn.lock index 6368217..cb57a94 100644 --- a/yarn.lock +++ b/yarn.lock @@ -115,6 +115,7 @@ __metadata: dependencies: eslint: ^7.32.0 prettier: ^2.4.1 + prettier-plugin-go-template: ^0.0.11 languageName: unknown linkType: soft @@ -796,6 +797,17 @@ __metadata: languageName: node linkType: hard +"prettier-plugin-go-template@npm:^0.0.11": + version: 0.0.11 + resolution: "prettier-plugin-go-template@npm:0.0.11" + dependencies: + ulid: ^2.3.0 + peerDependencies: + prettier: ^2.0.0 + checksum: 0c78d4f096d86d52fa40c11c81c4ab4b9d39732eb990fb5cb88bd2a43aefadf131d73d39f408446a805348117b5c69b441093e491ac175def86f83e38c7742ea + languageName: node + linkType: hard + "prettier@npm:^2.4.1": version: 2.4.1 resolution: "prettier@npm:2.4.1" @@ -978,6 +990,15 @@ __metadata: languageName: node linkType: hard +"ulid@npm:^2.3.0": + version: 2.3.0 + resolution: "ulid@npm:2.3.0" + bin: + ulid: ./bin/cli.js + checksum: d6dbf253fdc189f60fe2829d934ee5447b3dab62d05449a2e0fe89670d77087dd6eba4f844a69f9ffdb01384ec6fd97bdd9be638fc67d593569a45e8969f1e69 + languageName: node + linkType: hard + "uri-js@npm:^4.2.2": version: 4.4.1 resolution: "uri-js@npm:4.4.1"