mirror of
https://github.com/one-among-us/data.git
synced 2024-11-22 19:24:51 +08:00
[+] Server-side autocorrect
This commit is contained in:
parent
37c503b7ae
commit
00c074774d
@ -16,6 +16,7 @@
|
|||||||
"@swc/core": "^1.3.17",
|
"@swc/core": "^1.3.17",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"@types/node": "^18",
|
"@types/node": "^18",
|
||||||
|
"autocorrect-node": "^2.5.5",
|
||||||
"esbuild": "^0.15.14",
|
"esbuild": "^0.15.14",
|
||||||
"fs-extra": "^11.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import url from "url";
|
import url from "url";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
|
import autocorrect from "autocorrect-node";
|
||||||
|
|
||||||
import YAML from 'js-yaml';
|
import YAML from 'js-yaml';
|
||||||
import metadataParser from 'markdown-yaml-metadata-parser';
|
import metadataParser from 'markdown-yaml-metadata-parser';
|
||||||
@ -69,6 +70,9 @@ function buildPeopleInfoAndList() {
|
|||||||
.filter(cf => cf.endsWith('.json'))
|
.filter(cf => cf.endsWith('.json'))
|
||||||
.map(cf => JSON.parse(fs.readFileSync(path.join(commentPath, cf), 'utf-8')))
|
.map(cf => JSON.parse(fs.readFileSync(path.join(commentPath, cf), 'utf-8')))
|
||||||
|
|
||||||
|
// Autocorrect comment contents
|
||||||
|
info.comments.forEach(c => c.content = autocorrect.format(c.content))
|
||||||
|
|
||||||
// Write info.json
|
// Write info.json
|
||||||
fs.ensureDirSync(distPath);
|
fs.ensureDirSync(distPath);
|
||||||
fs.writeFileSync(path.join(distPath, `info${lang}.json`), JSON.stringify(info));
|
fs.writeFileSync(path.join(distPath, `info${lang}.json`), JSON.stringify(info));
|
||||||
@ -95,7 +99,12 @@ function buildPeoplePages() {
|
|||||||
for (const lang of ['', '.zh_hant'])
|
for (const lang of ['', '.zh_hant'])
|
||||||
{
|
{
|
||||||
// Read markdown page and remove markdown meta
|
// Read markdown page and remove markdown meta
|
||||||
const markdown = metadataParser(fs.readFileSync(path.join(srcPath, `page${lang}.md`), "utf-8")).content;
|
let markdown = metadataParser(fs.readFileSync(path.join(srcPath, `page${lang}.md`), "utf-8")).content;
|
||||||
|
|
||||||
|
// Autocorrect markdown
|
||||||
|
markdown = autocorrect.formatFor(markdown, 'markdown')
|
||||||
|
|
||||||
|
// Render mdx
|
||||||
const result = renderMdx(markdown);
|
const result = renderMdx(markdown);
|
||||||
|
|
||||||
fs.ensureDirSync(distPath);
|
fs.ensureDirSync(distPath);
|
||||||
|
30
yarn.lock
30
yarn.lock
@ -270,6 +270,36 @@ astring@^1.6.0, astring@^1.8.0:
|
|||||||
resolved "https://registry.yarnpkg.com/astring/-/astring-1.8.3.tgz#1a0ae738c7cc558f8e5ddc8e3120636f5cebcb85"
|
resolved "https://registry.yarnpkg.com/astring/-/astring-1.8.3.tgz#1a0ae738c7cc558f8e5ddc8e3120636f5cebcb85"
|
||||||
integrity sha512-sRpyiNrx2dEYIMmUXprS8nlpRg2Drs8m9ElX9vVEXaCB4XEAJhKfs7IcX0IwShjuOAjLR6wzIrgoptz1n19i1A==
|
integrity sha512-sRpyiNrx2dEYIMmUXprS8nlpRg2Drs8m9ElX9vVEXaCB4XEAJhKfs7IcX0IwShjuOAjLR6wzIrgoptz1n19i1A==
|
||||||
|
|
||||||
|
autocorrect-node-darwin-arm64@2.5.5:
|
||||||
|
version "2.5.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-arm64/-/autocorrect-node-darwin-arm64-2.5.5.tgz#2218e96a928229409bbf345c1ee3c00b9cd77fb4"
|
||||||
|
integrity sha512-l3O1jHEHbUMSzs68Myfhs31DdhnODAaxXPWt/i6V3ZSOK86HJICmkmvlGHdH1AmI3eS5DVXoWmP4UlVtvzxmPw==
|
||||||
|
|
||||||
|
autocorrect-node-darwin-x64@2.5.5:
|
||||||
|
version "2.5.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/autocorrect-node-darwin-x64/-/autocorrect-node-darwin-x64-2.5.5.tgz#21fe46b7fdbd35ef26cdb0c8c6cb6a7baf8ffac7"
|
||||||
|
integrity sha512-4KpUDkvCUZh3T3rsQRbeiidCykgWD3FdYxgXj4i2D7GZt9e82RqGuVzs+Hq3OYrhzBGMjh2Cx5IqaESY3UwCnw==
|
||||||
|
|
||||||
|
autocorrect-node-linux-x64-gnu@2.5.5:
|
||||||
|
version "2.5.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/autocorrect-node-linux-x64-gnu/-/autocorrect-node-linux-x64-gnu-2.5.5.tgz#34e343c18e10fbd6ccb7f37231ec097fca298ef0"
|
||||||
|
integrity sha512-8AMHVoVlJ1lKXFR3r6dFeQ6eWj1U6QVaVu8M2LkFWT7qPqQBae4FauB6c+XF7VhcCe5+DYAY4/astJzBc5MXjQ==
|
||||||
|
|
||||||
|
autocorrect-node-win32-x64-msvc@2.5.5:
|
||||||
|
version "2.5.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/autocorrect-node-win32-x64-msvc/-/autocorrect-node-win32-x64-msvc-2.5.5.tgz#ceb8727531536a9b56a637882f97d40a34c34741"
|
||||||
|
integrity sha512-f8K4SOxotVAKDmBdz5ytr2OWzI83jyijDAWDRfPl/VlmegU01NhOIcZp8Yt5sTIq8m7GBhaWaC6sCQL8nmdhSA==
|
||||||
|
|
||||||
|
autocorrect-node@^2.5.5:
|
||||||
|
version "2.5.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/autocorrect-node/-/autocorrect-node-2.5.5.tgz#7420e64fcbd339435994c54caafe6a567f22f20c"
|
||||||
|
integrity sha512-YJQZNJIOJn0j364+ORS2yOVCU1QzArODZIchSb7G7dLbApR+sa9o2G035RP9Ymn1QR8coWfoUOpWb9KYwKAEPw==
|
||||||
|
optionalDependencies:
|
||||||
|
autocorrect-node-darwin-arm64 "2.5.5"
|
||||||
|
autocorrect-node-darwin-x64 "2.5.5"
|
||||||
|
autocorrect-node-linux-x64-gnu "2.5.5"
|
||||||
|
autocorrect-node-win32-x64-msvc "2.5.5"
|
||||||
|
|
||||||
bail@^2.0.0:
|
bail@^2.0.0:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/bail/-/bail-2.0.2.tgz#d26f5cd8fe5d6f832a31517b9f7c356040ba6d5d"
|
resolved "https://registry.yarnpkg.com/bail/-/bail-2.0.2.tgz#d26f5cd8fe5d6f832a31517b9f7c356040ba6d5d"
|
||||||
|
Loading…
Reference in New Issue
Block a user