From 903bc812b663d69b12acef70aa1f98d1278ad11f Mon Sep 17 00:00:00 2001 From: Elihuso Quigley Date: Thu, 4 Apr 2024 19:47:23 +0800 Subject: [PATCH] [+] feature: entry won;t show on the homepage Feature requested by @Twinsherry --- scripts/build.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/build.ts b/scripts/build.ts index 2b122b3a..2b083a30 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -28,14 +28,14 @@ const people = fs.readdirSync(peopleDir).map(person => ({ })); interface HData { - commentOnly: string[], - exclude: string[], + commentOnly: string[] + exclude: string[] notShowOnHome: string[] } const hdata = JSON.parse(fs.readFileSync(path.join(projectRoot, DATA_DIR, "hdata.json")).toString()) as HData; const commentOnlyList = hdata.commentOnly; -const excludeList = hdata.exclude; +const excludeList = commentOnlyList.concat(hdata.exclude); const notShowOnHomeList = hdata.notShowOnHome; interface PeopleMeta { @@ -57,6 +57,7 @@ function buildPeopleInfoAndList() { // Compiled meta of list of people for the front page (contains keys id, name, profileUrl) const peopleList: PeopleMeta[] = []; + const peopleHomeList: PeopleMeta[] = []; // For each person for (const { dirname, srcPath, distPath } of people) { @@ -118,14 +119,19 @@ function buildPeopleInfoAndList() { } as PeopleMeta; // Add meta to people list - if (peopleList.filter(it => it.id == peopleMeta.id).length == 0) + if (peopleList.filter(it => it.id == peopleMeta.id).length == 0) { peopleList.push(peopleMeta); + if (!hdata.notShowOnHome.includes(peopleMeta.id)) + peopleHomeList.push(peopleMeta) + } } peopleList.sort((a, b) => b.sortKey.localeCompare(a.sortKey)) + peopleHomeList.sort((a, b) => b.sortKey.localeCompare(a.sortKey)) // Write people-list.json fs.writeFileSync(path.join(projectRoot, DIST_DIR, `people-list${lang}.json`), JSON.stringify(peopleList)); + fs.writeFileSync(path.join(projectRoot, DIST_DIR, `people-home-list${lang}.json`), JSON.stringify(peopleHomeList)); } }