mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
wiki
This commit is contained in:
1 parent
8c20c34d8b
commit
ca11d80776
45 files changed
+418
-444
No files matched your search
@@ -6,6 +6,7 @@ const yaml = require('js-yaml');
|
||||
const { root, ignoreFailure, rmdir } = require('./utils');
|
||||
const template = require('./template');
|
||||
const hack = require('./hack');
|
||||
const wikiBuild = require('./wiki');
|
||||
|
||||
const fsp = fs.promises;
|
||||
|
||||
@@ -42,6 +43,8 @@ async function build(type) {
|
||||
template: template('templates'),
|
||||
public: {},
|
||||
};
|
||||
const wiki = wikiBuild();
|
||||
builtin.lib = `Object.assign(global.Hydro.wiki,${JSON.stringify(wiki)})`;
|
||||
const files = getFiles('.uibuild');
|
||||
for (const f of files) {
|
||||
if (fs.statSync(root(`.uibuild/${f}`)).isDirectory()) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const fs = require('fs');
|
||||
const { root } = require('./utils');
|
||||
|
||||
module.exports = () => {
|
||||
const pages = fs.readdirSync(root('wiki'));
|
||||
const res = {};
|
||||
for (const page of pages) {
|
||||
const c = fs.readFileSync(root(`wiki/${page}`)).toString().split('\n');
|
||||
const pagename = page.split('.')[0];
|
||||
res[pagename] = [];
|
||||
let content = null;
|
||||
for (let i = 0; i < c.length; i++) {
|
||||
const line = c[i];
|
||||
if (line.startsWith('# ')) {
|
||||
if (content) res[pagename].push(content);
|
||||
content = {};
|
||||
const t = line.split('# ')[1].split('|');
|
||||
[content.title, content.id] = t.map((q) => q.trim());
|
||||
content.content = '';
|
||||
} else {
|
||||
content.content = `${content.content}${line}\n`;
|
||||
}
|
||||
res[pagename].push(content);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
Reference in new issue
Block a user