@@ -41,6 +41,18 @@ function safeReadDirSync(path) {
4141 return dirData
4242}
4343
44+ // collect unique tags from all articles.
45+ const tagsArr = [ ]
46+
47+ // The global arr cache has side effects, to follow up optimizing.
48+ // [{
49+ // tagName: 'customTag1', // tag type name
50+ // mapArticle: [{
51+ // path, // click tag to jump route such as /tags/customTag1
52+ // title // the name of article
53+ // }]
54+ // }]
55+ const mapTagsWithArticle = [ ]
4456/** build directory Tree, fork from https://github.com/mihneadb/node-directory-tree
4557 * path: path for file
4658 * options: {
@@ -50,19 +62,10 @@ function safeReadDirSync(path) {
5062 * prerender: Boolean. Used for prerender.
5163 * generate: Boolean. Used for generating info in front-matter.
5264 * }
53- * tagsArr: collect unique tags from all articles.
54- * mapTagsWithArticle: [{
55- * tagName: 'customTag1', // tag type name
56- * mapArticle: [{
57- * path, // click tag to jump route such as /tags/customTag1
58- * title // the name of article
59- * }]}]
6065 */
6166function directoryTree ( {
6267 path,
6368 options,
64- tagsArr = [ ] ,
65- mapTagsWithArticle = [ ] ,
6669 routePath = ''
6770} ) {
6871 const name = PATH . basename ( path , '.md' )
@@ -132,6 +135,8 @@ function directoryTree({
132135 title : name
133136 } ]
134137 } )
138+
139+ console . log ( 'mapTagsWithArticle222' , mapTagsWithArticle )
135140 }
136141 }
137142 }
@@ -171,8 +176,6 @@ function directoryTree({
171176 directoryTree ( {
172177 path : PATH . join ( path , child ) ,
173178 options,
174- tagsArr,
175- mapTagsWithArticle,
176179 routePath : routePropsCurrent
177180 } ) ,
178181 )
@@ -187,4 +190,7 @@ function directoryTree({
187190 return item
188191}
189192
190- module . exports = directoryTree
193+ module . exports = {
194+ directoryTree,
195+ mapTagsWithArticle
196+ }
0 commit comments