From 835ff07758be1f7b4b0ce3b117d1d897fe3594a6 Mon Sep 17 00:00:00 2001 From: Defectink Date: Mon, 18 Apr 2022 15:00:56 +0800 Subject: [PATCH] Updat build script --- package.json | 2 +- scripts/build-search.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6a6f468..55b47b5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "next build", + "build": "next build && node scripts/build-search.mjs", "start": "next start", "lint": "next lint", "test": "jest --watch", diff --git a/scripts/build-search.mjs b/scripts/build-search.mjs index 9cb27ce..a55041c 100644 --- a/scripts/build-search.mjs +++ b/scripts/build-search.mjs @@ -13,14 +13,14 @@ const postLists = () => { const files = fs.readdirSync(path.join('pages/p')); const myPosts = []; - files.map((f, fi) => { + files.map((f) => { const content = fs.readFileSync(path.join('pages/p', f), 'utf-8'); // const { data: meta, content } = matter(markdownWithMeta); const slug = f.replace(/\.mdx$/, ''); const regex = /^#{2}(?!#)(.*)/gm; - content.match(regex)?.map((heading, i) => { + content.match(regex)?.map((heading) => { myPosts.push({ content: null, hierarchy: {