From d05a01ea9e97b943a63cf9f4188b60c4dfbd5fef Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 19 May 2025 20:22:53 +0800 Subject: [PATCH] fix: search index name error --- components/pages/nav-bar.tsx | 2 +- scripts/build-search.mjs | 23 ++++++++++------------- scripts/posts/index.mjs | 7 +++++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/components/pages/nav-bar.tsx b/components/pages/nav-bar.tsx index 51c597c..2993939 100644 --- a/components/pages/nav-bar.tsx +++ b/components/pages/nav-bar.tsx @@ -139,7 +139,7 @@ const HeadBar = () => { {mounted ? ( arg === '-t'); - const gists = args.some((arg) => arg === '-g'); - isTest ? test(gists) : pushAlgolia(gists); + isTest ? test() : pushAlgolia(); } main(); diff --git a/scripts/posts/index.mjs b/scripts/posts/index.mjs index daefc70..0fce120 100644 --- a/scripts/posts/index.mjs +++ b/scripts/posts/index.mjs @@ -1,6 +1,7 @@ import path from 'path'; /* @ts-check */ import fs from 'fs/promises'; +import matter from 'gray-matter'; const dataPath = 'content/posts'; @@ -15,8 +16,9 @@ const postLists = async () => { const myPosts = []; const getFiles = async (f) => { - const content = await fs.readFile(path.join(dataPath, f), 'utf-8'); - // const { content: meta, content } = matter(markdownWithMeta); + const markdownWithMeta = await fs.readFile(path.join(dataPath, f), 'utf-8'); + const { content, data: meta } = matter(markdownWithMeta); + // console.log('meta', meta); const slug = f.replace(/\.mdx$/, ''); const regex = /^#{2,3}(?!#)(.*)/gm; @@ -40,6 +42,7 @@ const postLists = async () => { type: `lvl${level}`, objectID: url, url, + tag: meta.tags, }; switch (level) {