1
0
mirror of https://github.com/one-among-us/data.git synced 2024-11-22 03:04:51 +08:00

[M] serve english page data

This commit is contained in:
kuniklo 2023-03-14 09:23:55 +00:00
parent 38c00aadd0
commit ada88c5b2d
4 changed files with 14 additions and 4 deletions

1
.gitignore vendored
View File

@ -6,5 +6,6 @@ yarn-debug.log*
yarn-error.log*
.idea
.devcontainer
.DS_Store
._*

View File

@ -12,3 +12,10 @@ zh_hant:
born: 出生
died: 逝世
age: 年齡
en:
key:
alias: Alias
location: Location
born: Born
died: Left
age: Age

View File

@ -11,7 +11,8 @@
"scripts": {
"build": "node --loader ts-node/esm/transpile-only scripts/build.ts",
"build-preview": "yarn build && scripts/preview.sh",
"preview": "yarn build-preview && http-server dist"
"serve": "http-server --cors='*' dist",
"preview": "yarn build-preview && yarn serve"
},
"dependencies": {
"@mdx-js/mdx": "^2.1.5",

View File

@ -39,7 +39,7 @@ function buildPeopleInfoAndList() {
const infoKeys = YAML.load(fs.readFileSync('info-i18n.yml').toString())
// Compile into multiple languages
for (const lang of ['', '.zh_hant']) {
for (const lang of ['', '.zh_hant', '.en']) {
// Compiled meta of list of people for the front page (contains keys id, name, profileUrl)
const peopleList: PeopleMeta[] = [];
@ -114,8 +114,8 @@ function buildPeopleInfoAndList() {
// Render `people/${dirname}/page.md` to `dist/people/${dirname}/page.js`.
function buildPeoplePages() {
for (const { srcPath, distPath } of people) {
for (const lang of ['', '.zh_hant'])
for (const { dirname, srcPath, distPath } of people) {
for (const lang of ['', '.zh_hant', '.en'])
{
// Read markdown page and remove markdown meta
let markdown = metadataParser(fs.readFileSync(path.join(srcPath, `page${lang}.md`), "utf-8")).content;
@ -124,6 +124,7 @@ function buildPeoplePages() {
markdown = autocorrect.formatFor(markdown, 'markdown')
// Render mdx
console.log('GENERATED: '+dirname+lang)
const result = renderMdx(markdown);
fs.ensureDirSync(distPath);