[+] feature: entry won;t show on the homepage

Feature requested by @Twinsherry
pull/214/head
Elihuso Quigley 2024-04-04 19:47:23 +08:00
parent 188569aa91
commit 903bc812b6
1 changed files with 10 additions and 4 deletions

View File

@ -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));
}
}