mirror of
https://github.com/one-among-us/data.git
synced 2024-11-22 19:24:51 +08:00
[PR] Merge pull request #214 from LS-KR/main
[+] Detach people-list.json so that the homepage does not load specific entries
This commit is contained in:
commit
1f5e204b98
@ -1,3 +0,0 @@
|
|||||||
[
|
|
||||||
"tdor"
|
|
||||||
]
|
|
@ -1 +0,0 @@
|
|||||||
[]
|
|
7
data/hdata.json
Normal file
7
data/hdata.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"commentOnly": [
|
||||||
|
"tdor"
|
||||||
|
],
|
||||||
|
"exclude": [],
|
||||||
|
"notShowOnHome": []
|
||||||
|
}
|
@ -8,7 +8,7 @@ import metadataParser from 'markdown-yaml-metadata-parser';
|
|||||||
|
|
||||||
import { renderMdx } from "./mdx.js";
|
import { renderMdx } from "./mdx.js";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { Icon } from "./icon.js";
|
import { Icon, backSVG } from "./icon.js";
|
||||||
|
|
||||||
const PUBLIC_DIR = "public";
|
const PUBLIC_DIR = "public";
|
||||||
|
|
||||||
@ -27,8 +27,16 @@ const people = fs.readdirSync(peopleDir).map(person => ({
|
|||||||
distPath: path.join(projectRoot, DIST_DIR, PEOPLE_DIR, person)
|
distPath: path.join(projectRoot, DIST_DIR, PEOPLE_DIR, person)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const commentOnlyList = JSON.parse(fs.readFileSync(path.join(projectRoot, DATA_DIR, "comment-only.json")).toString()) as String[];
|
interface HData {
|
||||||
const excludeList = commentOnlyList.concat(JSON.parse(fs.readFileSync(path.join(projectRoot, DATA_DIR, 'exclude.json')).toString()) as 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 = commentOnlyList.concat(hdata.exclude);
|
||||||
|
const notShowOnHomeList = hdata.notShowOnHome;
|
||||||
|
|
||||||
interface PeopleMeta {
|
interface PeopleMeta {
|
||||||
id: string
|
id: string
|
||||||
@ -49,6 +57,7 @@ function buildPeopleInfoAndList() {
|
|||||||
|
|
||||||
// Compiled meta of list of people for the front page (contains keys id, name, profileUrl)
|
// Compiled meta of list of people for the front page (contains keys id, name, profileUrl)
|
||||||
const peopleList: PeopleMeta[] = [];
|
const peopleList: PeopleMeta[] = [];
|
||||||
|
const peopleHomeList: PeopleMeta[] = [];
|
||||||
|
|
||||||
// For each person
|
// For each person
|
||||||
for (const { dirname, srcPath, distPath } of people) {
|
for (const { dirname, srcPath, distPath } of people) {
|
||||||
@ -110,14 +119,19 @@ function buildPeopleInfoAndList() {
|
|||||||
} as PeopleMeta;
|
} as PeopleMeta;
|
||||||
|
|
||||||
// Add meta to people list
|
// 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);
|
peopleList.push(peopleMeta);
|
||||||
|
if (!notShowOnHomeList.includes(peopleMeta.id))
|
||||||
|
peopleHomeList.push(peopleMeta)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
peopleList.sort((a, b) => b.sortKey.localeCompare(a.sortKey))
|
peopleList.sort((a, b) => b.sortKey.localeCompare(a.sortKey))
|
||||||
|
peopleHomeList.sort((a, b) => b.sortKey.localeCompare(a.sortKey))
|
||||||
|
|
||||||
// Write people-list.json
|
// 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-list${lang}.json`), JSON.stringify(peopleList));
|
||||||
|
fs.writeFileSync(path.join(projectRoot, DIST_DIR, `people-home-list${lang}.json`), JSON.stringify(peopleHomeList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +171,7 @@ function handleFootnote(md: string) {
|
|||||||
// Replace footnote references with HTML superscript tags
|
// Replace footnote references with HTML superscript tags
|
||||||
return md.replace(/\[\^(\d+)\](?::\s*(.*))?/g, (match, id, text) => text ?
|
return md.replace(/\[\^(\d+)\](?::\s*(.*))?/g, (match, id, text) => text ?
|
||||||
// Footnote definition
|
// Footnote definition
|
||||||
`<li id="footnote-${id}">${text}<a href="#footnote-ref-${id}">↩</a></li>` :
|
`<li id="footnote-${id}">${text}<a href="#footnote-ref-${id}">${backSVG}</a></li>` :
|
||||||
// Footnote reference
|
// Footnote reference
|
||||||
`<sup><a href="#footnote-${id}" id="footnote-ref-${id}">${id}</a></sup>`
|
`<sup><a href="#footnote-${id}" id="footnote-ref-${id}">${id}</a></sup>`
|
||||||
)
|
)
|
||||||
|
@ -9,3 +9,5 @@ export const Icon = {
|
|||||||
TransFlag: `<svg style="display: inline-block; overflow: visible !important; vertical-align: sub; margin-right: 10px;" viewBox="0 0 32 32" width="16" height="16" aria-hidden="true"><path fill="#5BCEFA" d="M0 27c0 2.209 1.791 4 4 4h28c2.209 0 4-1.791 4-4v-1.3H0V27z"/><path fill="#F5A9B8" d="M.026 20.5L0 25.8h36v-5.3z"/><path fill="#EEE" d="M0 15.3h36v5.3H0z"/><path fill="#F5A9B8" d="M0 9.902h36V15.4H0z"/><path fill="#5BCEFA" d="M36 9c0-2.209-1.791-4-4-4H4C1.791 5 0 6.791 0 9v1.2h36V9z"/></svg>`,
|
TransFlag: `<svg style="display: inline-block; overflow: visible !important; vertical-align: sub; margin-right: 10px;" viewBox="0 0 32 32" width="16" height="16" aria-hidden="true"><path fill="#5BCEFA" d="M0 27c0 2.209 1.791 4 4 4h28c2.209 0 4-1.791 4-4v-1.3H0V27z"/><path fill="#F5A9B8" d="M.026 20.5L0 25.8h36v-5.3z"/><path fill="#EEE" d="M0 15.3h36v5.3H0z"/><path fill="#F5A9B8" d="M0 9.902h36V15.4H0z"/><path fill="#5BCEFA" d="M36 9c0-2.209-1.791-4-4-4H4C1.791 5 0 6.791 0 9v1.2h36V9z"/></svg>`,
|
||||||
Pride: `<svg style="display: inline-block; overflow: visible !important; vertical-align: sub; margin-right: 10px;" viewBox="0 0 32 32" width="16" height="16" aria-hidden="true"><path fill="#880082" d="M0 27a4 4 0 0 0 4 4h28a4 4 0 0 0 4-4v-.5H0v.5z"/><path fill="#3558A0" d="M0 22.07h36v4.6H0z"/><path fill="#138F3E" d="M0 17.83h36v4.5H0z"/><path fill="#FAD220" d="M0 13.5h36V18H0z"/><path fill="#FF7300" d="M0 9.17h36v4.5H0z"/><path fill="#FF000E" d="M32 5H4a4 4 0 0 0-4 4v.33h36V9a4 4 0 0 0-4-4z"/></svg>`,
|
Pride: `<svg style="display: inline-block; overflow: visible !important; vertical-align: sub; margin-right: 10px;" viewBox="0 0 32 32" width="16" height="16" aria-hidden="true"><path fill="#880082" d="M0 27a4 4 0 0 0 4 4h28a4 4 0 0 0 4-4v-.5H0v.5z"/><path fill="#3558A0" d="M0 22.07h36v4.6H0z"/><path fill="#138F3E" d="M0 17.83h36v4.5H0z"/><path fill="#FAD220" d="M0 13.5h36V18H0z"/><path fill="#FF7300" d="M0 9.17h36v4.5H0z"/><path fill="#FF000E" d="M32 5H4a4 4 0 0 0-4 4v.33h36V9a4 4 0 0 0-4-4z"/></svg>`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const backSVG = `<svg width="16" height="16"viewBox="0 0 16 16" version="1.1" id="svg1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> <defs id="defs1" /> <path style="opacity:1;fill:#fff9f9;fill-opacity:0.0199483;stroke:#ff8373;stroke-width:0.839;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" d="m 10,4.0031 c 0,0 4.003714,0.3021906 4.001025,4.1458036 C 13.998336,11.992517 10,12.004973 10,12.004973 l -8,-0.0267" id="path1" /> <path style="opacity:1;fill:#fff9f9;fill-opacity:0.0199483;stroke:#ff8373;stroke-width:0.839;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" d="M 3.3112984,10.696288 2,11.978273 3.2812828,13.265655" id="path2" /></svg>`
|
Loading…
Reference in New Issue
Block a user