From 9d493413c84e60fe287bf3a3c150663b552ea3f2 Mon Sep 17 00:00:00 2001 From: Devon Campbell Date: Mon, 24 Jun 2024 00:22:24 -0400 Subject: [PATCH] Add syntax highlighting --- .eleventy.js | 13 ++++ css/prism-synthwave84.css | 140 ++++++++++++++++++++++++++++++++++++++ package-lock.json | 15 ++++ package.json | 1 + 4 files changed, 169 insertions(+) create mode 100644 css/prism-synthwave84.css diff --git a/.eleventy.js b/.eleventy.js index b4d9775..65d3262 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -8,6 +8,7 @@ const markdownItEleventyImg = require("markdown-it-eleventy-img"); const pluginRss = require("@11ty/eleventy-plugin-rss"); const embedYouTube = require("eleventy-plugin-youtube-embed"); const sanitizeHtml = require("sanitize-html"); +const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const metadata = require("./src/_data/metadata.json"); const sanitize = (html) => { @@ -20,6 +21,7 @@ const sanitize = (html) => { module.exports = function(eleventyConfig) { eleventyConfig.addPlugin(embedYouTube); eleventyConfig.addPlugin(pluginRss); + eleventyConfig.addPlugin(syntaxHighlight); eleventyConfig.addPassthroughCopy("css"); eleventyConfig.addPassthroughCopy("fonts"); @@ -108,6 +110,17 @@ module.exports = function(eleventyConfig) { return sortedMentions; }); + eleventyConfig.addTransform('includePrismTheme', function(content, outputPath) { + // Automatically inject the Prism theme CSS, but only in HTML files that need it. + if (outputPath.endsWith('.html') && content.includes('