Skip to content

Commit 55b23d5

Browse files
committed
chore(scripts): update docs build script
1 parent 3a53569 commit 55b23d5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

scripts/main/utils/handler-cates.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NcCate, NcCates, NcCode, NcCodeBox } from '../interfaces/examples';
44
import { parseMdDoc } from '.';
55
import { sortBy } from 'lodash';
66
import { NcPage } from '../interfaces/page';
7+
import { NcTemplate } from '../interfaces/template';
78

89
/**
910
* 示例分类处理
@@ -26,11 +27,7 @@ export function hanlderCates(cates: NcCates, page: NcPage) {
2627
label: readme.meta.label,
2728
path: catePath
2829
};
29-
handlerCodeBoxes(cate, readme);
30-
if (cate.className) {
31-
mod.syswords.declarations += `, ${cate.className}`;
32-
mod.syswords.imports += `import { ${cate.className} } from '${cate.rootPath.replace(`/${page.lang}/`, '/')}';\n`;
33-
}
30+
handlerCodeBoxes(cate, readme, mod, page);
3431
cates.list.push(cate);
3532
cates.list = sortBy(cates.list, 'order');
3633
}
@@ -45,7 +42,7 @@ export function hanlderCates(cates: NcCates, page: NcPage) {
4542
* @param {NcCate} cate
4643
* @param {*} readme
4744
*/
48-
export function handlerCodeBoxes(cate: NcCate, readme) {
45+
export function handlerCodeBoxes(cate: NcCate, readme, module: NcTemplate, page: NcPage) {
4946
let folder = fs.readdirSync(cate.path, 'utf8');
5047
let box: NcCodeBox = {
5148
codes: [],
@@ -60,6 +57,7 @@ export function handlerCodeBoxes(cate: NcCate, readme) {
6057
subType: subType.slice(subType.lastIndexOf('.') + 1, subType.length),
6158
content: fs.readFileSync(path.join(cate.path, x), 'utf8')
6259
};
60+
6361
if (code.type === 'ts' && code.subType === 'component') {
6462
const matchSelector = code.content.match(/selector: \'(\S*)\',/);
6563
const matchClassName = code.content.match(/export class (\S*) /);
@@ -69,6 +67,10 @@ export function handlerCodeBoxes(cate: NcCate, readme) {
6967
0,
7068
x.lastIndexOf(code.type) - 1
7169
)}`;
70+
if (cate.className) {
71+
module.syswords.declarations += `, ${cate.className}`;
72+
module.syswords.imports += `import { ${cate.className} } from '${cate.rootPath.replace(`/${page.lang}/`, '/')}';\n`;
73+
}
7274
}
7375
box.codes.push(code);
7476
}

0 commit comments

Comments
 (0)