From ba73e0d97a89df79726303f5a0c8a96abd2e6229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:34:50 +0100 Subject: [PATCH] Fix syntax highlighting and click-to-copy buttons for code blocks (#2049) --- .../internal/newsfragments/2049.clarification | 1 + postcss.config.js | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 changelogs/internal/newsfragments/2049.clarification diff --git a/changelogs/internal/newsfragments/2049.clarification b/changelogs/internal/newsfragments/2049.clarification new file mode 100644 index 00000000..5a6e90f1 --- /dev/null +++ b/changelogs/internal/newsfragments/2049.clarification @@ -0,0 +1 @@ +Fix syntax highlighting and click-to-copy buttons for code blocks by purging less CSS. diff --git a/postcss.config.js b/postcss.config.js index ecd78497..50e7224f 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,11 +1,21 @@ // Remove unused CSS selectors. const purgecss = require('@fullhuman/postcss-purgecss')({ - // Use stats generated by Hugo. - content: [ './hugo_stats.json' ], - defaultExtractor: (content) => { - let els = JSON.parse(content).htmlElements; - return els.tags.concat(els.classes, els.ids); - } + content: [ + // Use stats generated by Hugo from HTML content. + './hugo_stats.json', + // Add used JS scripts. + process.env.HUGO_PUBLISHDIR + '/js/click-to-copy.min.*.js', + process.env.HUGO_PUBLISHDIR + '/js/main.min.*.js', + ], + extractors: [ + { + extractor: (content) => { + let els = JSON.parse(content).htmlElements; + return els.tags.concat(els.classes, els.ids); + }, + extensions: ["json"], + }, + ], }); module.exports = {