@@ -6,10 +6,12 @@ const { execSync } = require('child_process')
66const {
77 replaceForFrontMatter,
88 generateRandomId,
9- getStrAfterPointed
9+ // getDocsConfig
1010} = require ( 'crd-utils' )
1111const { getDigitFromDir, timeFormat } = require ( '../utils' )
1212
13+ // const docsConfig = getDocsConfig()
14+
1315const constants = {
1416 DIRECTORY : 'directory' ,
1517 FILE : 'file' ,
@@ -57,12 +59,12 @@ function directoryTree({
5759 options,
5860 tagsArr = [ ] ,
5961 // [{ tagName: 'custom Tag 1', mapArticle: [{ path, title }] }]
60- mapTagsWithArticle = [ ]
62+ mapTagsWithArticle = [ ] ,
63+ routePath = ''
6164} ) {
62- console . log ( '✅✅ path' , path )
6365 const name = PATH . basename ( path )
64- console . log ( '✅✅ name' , name )
6566 const item = { name }
67+ const routePropsCurrent = `${ routePath } /${ name } ` . replace ( / .m d $ / , '' )
6668 if ( ! options . prerender ) {
6769 item . path = path
6870 }
@@ -108,25 +110,23 @@ function directoryTree({
108110
109111 const yamlParse = contentMatch ? YAML . parse ( contentMatch [ 1 ] ) : { }
110112 const articleTags = yamlParse . tags
111- const pathResult = yamlParse . abbrlink
113+ const abbrlink = yamlParse . abbrlink
112114 if ( Array . isArray ( articleTags ) ) {
113115 const cpArticleTags = Array . from ( new Set ( articleTags ) )
114-
115116 for ( let i = 0 ; i < cpArticleTags . length ; i ++ ) {
116117 const articleTag = cpArticleTags [ i ]
117118 const articleTagIndex = tagsArr . indexOf ( articleTag )
118119 if ( articleTagIndex > - 1 ) {
119120 mapTagsWithArticle [ articleTagIndex ] [ 'mapArticle' ] . push ( {
120- path : pathResult ? pathResult : name ,
121+ path : abbrlink ? `/ ${ abbrlink } ` : routePropsCurrent ,
121122 title : name
122123 } )
123124 } else {
124125 tagsArr . push ( cpArticleTags [ i ] )
125126 mapTagsWithArticle . push ( {
126127 tagName : cpArticleTags [ i ] ,
127128 mapArticle : [ {
128- // todo: replace name
129- path : pathResult ? pathResult : name ,
129+ path : abbrlink ? `/${ abbrlink } ` : routePropsCurrent ,
130130 title : name
131131 } ]
132132 } )
@@ -170,7 +170,8 @@ function directoryTree({
170170 path : PATH . join ( path , child ) ,
171171 options,
172172 tagsArr,
173- mapTagsWithArticle
173+ mapTagsWithArticle,
174+ routePath : routePropsCurrent
174175 } ) ,
175176 )
176177 . filter ( e => ! ! e )
0 commit comments