From 26071f3e6ad5c5878608a44912759210413a06b4 Mon Sep 17 00:00:00 2001 From: jpaquim Date: Thu, 8 Aug 2024 23:39:53 +0000 Subject: [PATCH] Fix vite update breaking changes --- src/lib/pages.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/pages.js b/src/lib/pages.js index ce53a5b..c3982c9 100644 --- a/src/lib/pages.js +++ b/src/lib/pages.js @@ -7,8 +7,8 @@ const prefix = '/content/'; const suffix = '.md'; // vite does not support variables in glob imports, but the glob should match // const pattern = `${prefix}*${suffix}` -const imports = import.meta.globEager('/content/*.md'); -const importsRaw = import.meta.globEager('/content/*.md', { as: 'raw' }); +const imports = import.meta.glob('/content/*.md', { eager: true }); +const importsRaw = import.meta.glob('/content/*.md', { eager: true, query: '?raw' }); /** derive the file path from the corresponding slug, and the base folder prefix * and extension suffix, redirecting '' -> index @@ -59,7 +59,7 @@ export const pages = Object.entries(imports).map(([path, module], index) => { const linkSlug = hrefToSlug(href); backlinks[linkSlug] = backlinks[linkSlug]?.concat(slug) ?? [slug]; }); - const md = importsRaw[path]; + const md = importsRaw[path].default; const fmEnd = md.lastIndexOf(fmMarker) + fmMarker.length; const scriptEnd = md.lastIndexOf(scriptMarker) + scriptMarker.length; // TODO: index html text elements only?