mirror of
https://github.com/one-among-us/data.git
synced 2024-11-10 13:24:50 +08:00
[O] Use list
This commit is contained in:
parent
a08c2c6320
commit
cd771e609a
3
data/comment-only.json
Normal file
3
data/comment-only.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[
|
||||||
|
"tdor"
|
||||||
|
]
|
1
data/exclude.json
Normal file
1
data/exclude.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[]
|
@ -17,6 +17,8 @@ const COMMENTS_DIR = "comments";
|
|||||||
|
|
||||||
const DIST_DIR = "dist";
|
const DIST_DIR = "dist";
|
||||||
|
|
||||||
|
const DATA_DIR = "data";
|
||||||
|
|
||||||
const projectRoot = path.dirname(path.dirname(url.fileURLToPath(import.meta.url)));
|
const projectRoot = path.dirname(path.dirname(url.fileURLToPath(import.meta.url)));
|
||||||
const peopleDir = path.join(projectRoot, PEOPLE_DIR);
|
const peopleDir = path.join(projectRoot, PEOPLE_DIR);
|
||||||
const people = fs.readdirSync(peopleDir).map(person => ({
|
const people = fs.readdirSync(peopleDir).map(person => ({
|
||||||
@ -25,6 +27,9 @@ 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[];
|
||||||
|
const excludeList = commentOnlyList.concat(JSON.parse(fs.readFileSync(path.join(projectRoot, DATA_DIR, 'exclude.json')).toString()) as String[]);
|
||||||
|
|
||||||
interface PeopleMeta {
|
interface PeopleMeta {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
@ -48,7 +53,7 @@ function buildPeopleInfoAndList() {
|
|||||||
// For each person
|
// For each person
|
||||||
for (const { dirname, srcPath, distPath } of people) {
|
for (const { dirname, srcPath, distPath } of people) {
|
||||||
|
|
||||||
if (dirname == 'tdor') continue;
|
if (excludeList.includes(dirname)) continue;
|
||||||
|
|
||||||
const infoFile = fs.readFileSync(path.join(srcPath, `info.yml`), "utf-8");
|
const infoFile = fs.readFileSync(path.join(srcPath, `info.yml`), "utf-8");
|
||||||
const info: any = YAML.load(infoFile);
|
const info: any = YAML.load(infoFile);
|
||||||
@ -119,7 +124,9 @@ function buildPeopleInfoAndList() {
|
|||||||
// Render `people/${dirname}/page.md` to `dist/people/${dirname}/page.js`.
|
// Render `people/${dirname}/page.md` to `dist/people/${dirname}/page.js`.
|
||||||
function buildPeoplePages() {
|
function buildPeoplePages() {
|
||||||
for (const { dirname, srcPath, distPath } of people) {
|
for (const { dirname, srcPath, distPath } of people) {
|
||||||
if (dirname == 'tdor') continue;
|
|
||||||
|
if (excludeList.includes(dirname)) continue;
|
||||||
|
|
||||||
for (const lang of ['', '.zh_hant', '.en'])
|
for (const lang of ['', '.zh_hant', '.en'])
|
||||||
{
|
{
|
||||||
// Read markdown page and remove markdown meta
|
// Read markdown page and remove markdown meta
|
||||||
@ -185,9 +192,10 @@ function copyPublic() {
|
|||||||
fs.copySync(path.join(projectRoot, PUBLIC_DIR), path.join(projectRoot, DIST_DIR));
|
fs.copySync(path.join(projectRoot, PUBLIC_DIR), path.join(projectRoot, DIST_DIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyTDORComments() {
|
function copyComments() {
|
||||||
const commentPath = path.join(peopleDir, 'tdor', COMMENTS_DIR);
|
for (const dirname of commentOnlyList) {
|
||||||
const distPath = path.join(projectRoot, DIST_DIR, PEOPLE_DIR, 'tdor');
|
const commentPath = path.join(peopleDir, dirname as string, COMMENTS_DIR);
|
||||||
|
const distPath = path.join(projectRoot, DIST_DIR, PEOPLE_DIR, dirname as string);
|
||||||
fs.ensureDirSync(commentPath);
|
fs.ensureDirSync(commentPath);
|
||||||
var info = { comments: [] };
|
var info = { comments: [] };
|
||||||
info.comments = fs
|
info.comments = fs
|
||||||
@ -198,17 +206,15 @@ function copyTDORComments() {
|
|||||||
);
|
);
|
||||||
info.comments.forEach((c) => (c.content = autocorrect.format(c.content)));
|
info.comments.forEach((c) => (c.content = autocorrect.format(c.content)));
|
||||||
fs.ensureDirSync(distPath);
|
fs.ensureDirSync(distPath);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(path.join(distPath, "info.json"), JSON.stringify(info));
|
||||||
path.join(distPath, 'info.json'),
|
}
|
||||||
JSON.stringify(info)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildPeopleInfoAndList();
|
buildPeopleInfoAndList();
|
||||||
buildPeoplePages();
|
buildPeoplePages();
|
||||||
copyPeopleAssets();
|
copyPeopleAssets();
|
||||||
copyPublic();
|
copyPublic();
|
||||||
copyTDORComments();
|
copyComments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trim a specific char from a string
|
* Trim a specific char from a string
|
||||||
|
Loading…
Reference in New Issue
Block a user