From 7564e42dbf3c3ee02a4318d5e76bbf9e200b829d Mon Sep 17 00:00:00 2001 From: Mat Manna Date: Tue, 9 Jun 2026 18:32:35 -0400 Subject: [PATCH] feat: update doctored and improve post-build --- Gemfile | 2 +- scripts/post-build.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b413d00..14eef43 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ source "https://rubygems.org" -gem "jekyll-theme-doctored", "~> 0.3.24" +gem "jekyll-theme-doctored", "~> 0.3.25" diff --git a/scripts/post-build.js b/scripts/post-build.js index dde45fd..769cab8 100644 --- a/scripts/post-build.js +++ b/scripts/post-build.js @@ -28,10 +28,33 @@ function getVarShortName(num) { return '--' + result; } +function stripPalette(html) { + // Strip duplicate Tailwind base reset blocks from inline palette + // These duplicate the same --tw-* vars already in :root + const before = html.length; + html = html.replace(/\*,:after,:before\{--tw-[^}]*\}/g, ''); + html = html.replace(/::backdrop\{--tw-[^}]*\}/g, ''); + + // Strip prose rules for elements never used anywhere on the site + const deadElements = ['pre', 'blockquote', 'kbd', 'table', 'thead', 'tbody', 'tfoot', 'figure', 'figcaption', 'dl', 'dt', 'dd']; + deadElements.forEach(el => { + const regex = new RegExp('\\.prose :where\\([^)]*\\b' + el + '\\b[^)]*\\):not\\(:where\\(\\[class~=not-prose\\],\\[class~=not-prose\\] \\*\\)\\)\\{[^}]*\\}', 'g'); + html = html.replace(regex, ''); + }); + + if (html.length < before) { + console.log('Palette optimized: ' + (before - html.length) + ' bytes'); + } + return html; +} + function processFile(filePath) { let html = fs.readFileSync(filePath, 'utf8'); let modified = false; + // Optimize palette CSS before class renaming (selectors still say .prose) + html = stripPalette(html); + const matches = html.match(/class="[^"]+"/g) || []; // Collect --tw-* variables (first file only, or reset per file - using global map) -- 2.51.2