✌️
This commit is contained in:
parent
5725e39a70
commit
169b99a358
12 changed files with 220 additions and 84 deletions
36
src/web/docs/vars.ts
Normal file
36
src/web/docs/vars.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import * as fs from 'fs';
|
||||
import * as glob from 'glob';
|
||||
import * as yaml from 'js-yaml';
|
||||
|
||||
export default function() {
|
||||
const vars = {};
|
||||
|
||||
const endpoints = glob.sync('./src/web/docs/api/endpoints/**/*.yaml');
|
||||
vars['endpoints'] = endpoints.map(ep => {
|
||||
const _ep = yaml.safeLoad(fs.readFileSync(ep, 'utf-8'));
|
||||
return _ep.endpoint;
|
||||
});
|
||||
|
||||
const entities = glob.sync('./src/web/docs/api/entities/**/*.yaml');
|
||||
vars['entities'] = entities.map(x => {
|
||||
const _x = yaml.safeLoad(fs.readFileSync(x, 'utf-8'));
|
||||
return _x.name;
|
||||
});
|
||||
|
||||
const docs = glob.sync('./src/web/docs/**/*.*.pug');
|
||||
vars['docs'] = {};
|
||||
docs.forEach(x => {
|
||||
const [, name, lang] = x.match(/docs\/(.+?)\.(.+?)\.pug$/);
|
||||
if (vars['docs'][name] == null) {
|
||||
vars['docs'][name] = {
|
||||
name,
|
||||
title: {}
|
||||
};
|
||||
}
|
||||
vars['docs'][name]['title'][lang] = fs.readFileSync(x, 'utf-8').match(/\r\n\th1 (.+?)\r\n/)[1];
|
||||
});
|
||||
|
||||
vars['kebab'] = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/\s+/g, '-').toLowerCase();
|
||||
|
||||
return vars;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue