upgrade katex to 0.12, wiki load

This commit is contained in:
undefined committed 2020-07-16 20:00:48 +08:00
1 parent 3b9910529e
commit bf29661eaa
18 files changed
+189 -54

No files matched your search

+5 -5
View File
@@ -218,21 +218,22 @@ export async function wiki(pending: string[], fail: string[]) {
const p = path.resolve(i, 'wiki');
if (fs.existsSync(p) && fs.statSync(p).isDirectory() && !fail.includes(i)) {
try {
const r = {};
const categories = fs.readdirSync(p);
for (const category of categories) {
console.log('category', category);
if (!fs.statSync(p).isDirectory()) return;
const pages = fs.readdirSync(path.join(p, category));
const res = {};
if (!global.Hydro.wiki[category]) global.Hydro.wiki[category] = {};
console.log(pages);
for (const page of pages) {
const c = fs.readFileSync(path.join(p, category, page)).toString().split('\n');
const pagename = page.split('.')[0];
res[pagename] = [];
global.Hydro.wiki[category][pagename] = [];
let content = null;
for (let j = 0; j < c.length; j++) {
const line = c[j];
if (line.startsWith('# ')) {
if (content) res[pagename].push(content);
if (content) global.Hydro.wiki[category][pagename].push(content);
content = {};
const t = line.split('# ')[1].split('|');
[content.title, content.id] = t.map((q) => q.trim());
@@ -242,7 +243,6 @@ export async function wiki(pending: string[], fail: string[]) {
}
}
}
r[category] = res;
}
console.log(`Wiki init: ${i}`);
} catch (e) {
-3
View File
@@ -44,9 +44,6 @@ export async function load() {
const files = fs.readdirSync(moduleRoot);
for (const file of files) {
try {
// This fixs a mistake.
// Markdown-it-katex is not a hydro module but a dependency.
if (file === 'markdown-it-katex') continue;
const modulePath = path.join(moduleRoot, file);
const packagejson = path.join(modulePath, 'package.json');
if (fs.statSync(modulePath).isFile() && file.endsWith('.hydro')) {
-1
View File
@@ -56,7 +56,6 @@ export async function load() {
}
}
for (const i of builtinScript) require(`../script/${i}`);
await wiki(pending, fail);
await script(pending, fail, active);
for (const postInit of global.Hydro.postInit) {
await postInit();