GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — lowcode-engine/docs/scripts/getDocsFromDir.js at main · Luckyseal/lowcode-engine Expand file tree/ Copy pathgetDocsFromDir.jsMore file actions 66 lines (58 loc) · 1.65 KB / Copy pathgetDocsFromDir.jsFile metadata and controls66 lines (58 loc) · 1.65 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 const fs = require('fs'); const path = require('path'); const glob = require('glob'); const matter = require('gray-matter'); module.exports = function getDocsFromDir(dir, cateList) { // docs/ const baseDir = path.join(__dirname, '../docs/'); const docsDir = path.join(baseDir, dir); function isNil(value) { return value === undefined || value === null; } function getMarkdownOrder(filepath) { const { data } = matter(fs.readFileSync(filepath, 'utf-8')); const { sidebar_position } = data || {}; return isNil(sidebar_position) ? 100 : sidebar_position; } const docs = glob.sync('*.md?(x)', { cwd: docsDir, // ignore: 'README.md', }); const result = docs .filter((doc) => !/^index.md(x)?$/.test(doc)) .map((doc) => { return path.join(docsDir, doc); }) .sort((a, b) => { const orderA = getMarkdownOrder(a); const orderB = getMarkdownOrder(b); return orderA - orderB; }) .map((filepath) => { // /Users/xxx/site/docs/guide/basic/router.md => guide/basic/router const id = path .relative(baseDir, filepath) .replace(/\\/g, '/') .replace(/\.mdx?/, ''); return id; }); (cateList || []).forEach((item) => { const { dir, subCategory, ...otherConfig } = item; const indexList = glob.sync('index.md?(x)', { cwd: path.join(baseDir, dir), }); if (indexList.length > 0) { otherConfig.link = { type: 'doc', id: `${dir}/index`, }; } result.push({ type: 'category', collapsed: false, ...otherConfig, items: getDocsFromDir(dir, subCategory), }); }); return result; }; |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |