Skip to content

Commit

Permalink
fix: add id index for mini search
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmubdyMutaikhan committed Nov 23, 2024
1 parent 9faec43 commit 94de470
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/scripts/build_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const jsonArr = [];
function parseMetadata(dir, specifyContent) {
try {
const files = fs.readdirSync(dir);

let id = 0;
for (const file of files) {
const filePath = path.join(dir, file);

Expand All @@ -23,11 +23,13 @@ function parseMetadata(dir, specifyContent) {
const index = fs.readFileSync(filePath, "utf8");
const { data, content } = matter(index);
if(specifyContent) {
jsonArr.push({...data, content });
jsonArr.push({...data, content, id });
} else {
jsonArr.push(data);
}
}

id += 1;
}
} catch (err) {
console.log(err);
Expand Down

0 comments on commit 94de470

Please sign in to comment.