From 153480375031a99bdaf5b1923147c4fe51e24fa9 Mon Sep 17 00:00:00 2001 From: Martijn Saelens Date: Mon, 26 Aug 2024 13:27:40 +0200 Subject: [PATCH] Also copy images in HTML tags to static directory --- lib/static.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/static.js b/lib/static.js index 3fb607f..fec9ab3 100644 --- a/lib/static.js +++ b/lib/static.js @@ -19,8 +19,9 @@ import featuredSlide from './featured-slide.js'; const files = new Set(); -const htmlImageRE = /!\[.*?\]\((.+?)\)/g; -const htmlImageBackgroundRE = //g; +const markdownImageRE = /!\[.*?\]\((.+?)\)/g; +const htmlImageRE = //g; +const markdownImageBackgroundRE = //g; const relativeDir = (from, to) => path.relative(from, to).replace(/^\.\./, '.'); @@ -74,9 +75,10 @@ const copyAssetsAndWriteFile = async (sourceDir, file, targetDir) => { const base = relativeDir(file, '.'); const markup = await renderFile(path.join(sourceDir, file), { base }); - const images = markdown.matchAll(htmlImageRE); - const backgroundImages = markdown.matchAll(htmlImageBackgroundRE); - const allImages = [...images, ...backgroundImages]; + const markdownImages = markdown.matchAll(markdownImageRE); + const htmlImages = markdown.matchAll(htmlImageRE); + const backgroundImages = markdown.matchAll(markdownImageBackgroundRE); + const allImages = [...markdownImages, ...htmlImages, ...backgroundImages]; for (let image of allImages) { const [, imgPath] = image;