From 39606e8bfbbdf37acac13e05aa5fc884a2eaed56 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Wed, 7 Aug 2024 18:35:33 -0700 Subject: Update pagefind --- static/js/pagefind.index.cjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'static/js/pagefind.index.cjs') diff --git a/static/js/pagefind.index.cjs b/static/js/pagefind.index.cjs index 8a685c0..1fea6dc 100644 --- a/static/js/pagefind.index.cjs +++ b/static/js/pagefind.index.cjs @@ -64,7 +64,7 @@ async function createIndex() { }) .then(async () => { // Edit the pagefind to convert from MJS to CJS - const pagefindPath = path.join(__dirname, "pagefind.js"); + const pagefindPath = path.join(__dirname, "pagefind.js");//source pagefind from node module let pagefindContent = fs.readFileSync(pagefindPath, "utf8"); // Remove 'import.meta.url' from the pagefind file and exports pagefindContent = pagefindContent @@ -74,6 +74,15 @@ async function createIndex() { ) // Remove annoying function .replace(/;export\{[^}]*\}/g, ""); fs.writeFileSync(pagefindPath, pagefindContent); + + // now insert the CJS into the anonymous function within pagefind.search.js + const pagefind_searchPath = path.join(__dirname, "pagefind.search.js");//file to insert into + const search_pagefindPath = path.join(__dirname, "search_pagefind.js");//output + let pagefind_searchContent = fs.readFileSync(pagefind_searchPath, "utf8"); + // Now insert into pagefind.search.js at this location: //insertHere + pagefind_searchContent = pagefind_searchContent.replace(/\/\/insertHere/g, pagefindContent); + fs.writeFileSync(search_pagefindPath, pagefind_searchContent); + }) .then(async () => { await pagefind.close(); -- cgit v1.3.1