@@ -4,6 +4,7 @@ import { NcCate, NcCates, NcCode, NcCodeBox } from '../interfaces/examples';
4
4
import { parseMdDoc } from '.' ;
5
5
import { sortBy } from 'lodash' ;
6
6
import { NcPage } from '../interfaces/page' ;
7
+ import { NcTemplate } from '../interfaces/template' ;
7
8
8
9
/**
9
10
* 示例分类处理
@@ -26,11 +27,7 @@ export function hanlderCates(cates: NcCates, page: NcPage) {
26
27
label : readme . meta . label ,
27
28
path : catePath
28
29
} ;
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 ) ;
34
31
cates . list . push ( cate ) ;
35
32
cates . list = sortBy ( cates . list , 'order' ) ;
36
33
}
@@ -45,7 +42,7 @@ export function hanlderCates(cates: NcCates, page: NcPage) {
45
42
* @param {NcCate } cate
46
43
* @param {* } readme
47
44
*/
48
- export function handlerCodeBoxes ( cate : NcCate , readme ) {
45
+ export function handlerCodeBoxes ( cate : NcCate , readme , module : NcTemplate , page : NcPage ) {
49
46
let folder = fs . readdirSync ( cate . path , 'utf8' ) ;
50
47
let box : NcCodeBox = {
51
48
codes : [ ] ,
@@ -60,6 +57,7 @@ export function handlerCodeBoxes(cate: NcCate, readme) {
60
57
subType : subType . slice ( subType . lastIndexOf ( '.' ) + 1 , subType . length ) ,
61
58
content : fs . readFileSync ( path . join ( cate . path , x ) , 'utf8' )
62
59
} ;
60
+
63
61
if ( code . type === 'ts' && code . subType === 'component' ) {
64
62
const matchSelector = code . content . match ( / s e l e c t o r : \' ( \S * ) \' , / ) ;
65
63
const matchClassName = code . content . match ( / e x p o r t c l a s s ( \S * ) / ) ;
@@ -69,6 +67,10 @@ export function handlerCodeBoxes(cate: NcCate, readme) {
69
67
0 ,
70
68
x . lastIndexOf ( code . type ) - 1
71
69
) } `;
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
+ }
72
74
}
73
75
box . codes . push ( code ) ;
74
76
}
0 commit comments