Skip to content

Commit 56f04ed

Browse files
committed
fix: solve duplaction tags problem
1 parent d72d7c3 commit 56f04ed

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const { directoryTree } = require('./node-directory-tree')
2+
3+
const getDirTree = (cmd) => {
4+
const dir = cmd.markdownPaths
5+
const dirs = Array.isArray(dir) ? dir : [dir]
6+
const otherProps = {
7+
mdconf: true,
8+
extensions: /\.md/,
9+
prerender: true,
10+
}
11+
const mapTagsWithArticle = []
12+
const dirTree = dirs.map(path => directoryTree({
13+
path,
14+
options: otherProps,
15+
mapTagsWithArticle
16+
}))
17+
return {
18+
dirTree,
19+
// map tags with path. [{ tagName: 'custom Tag 1', mapArticle: [{ path, name }]}]
20+
mapTagsWithArticle
21+
}
22+
}
23+
24+
module.exports = {
25+
getDirTree,
26+
}

packages/crd-scripts/src/conf/getPrerenderRoutes.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
const { directoryTree } = require('./node-directory-tree')
2-
3-
const getDirTree = (cmd) => {
4-
const dir = cmd.markdownPaths
5-
const dirs = Array.isArray(dir) ? dir : [dir]
6-
const otherProps = {
7-
mdconf: true,
8-
extensions: /\.md/,
9-
prerender: true,
10-
}
11-
const mapTagsWithArticle = []
12-
const dirTree = dirs.map(path => directoryTree({
13-
path,
14-
options: otherProps,
15-
mapTagsWithArticle
16-
}))
17-
return {
18-
dirTree,
19-
// map tags with path. [{ tagName: 'custom Tag 1', mapArticle: [{ path, name }]}]
20-
mapTagsWithArticle
21-
}
22-
}
23-
241
// eg: ['docs/quick_start.md', 'a']
252
// output: ['/quick_start', '/a/b', '/a/b/c']
263
const getPrerenderRoutes = (dirTree) => {
@@ -70,6 +47,5 @@ function recursive(
7047
}
7148

7249
module.exports = {
73-
getDirTree,
7450
getPrerenderRoutes
7551
}

packages/crd-scripts/src/conf/node-directory-tree.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ function directoryTree({
134134
title: name
135135
}]
136136
})
137-
138-
console.log('mapTagsWithArticle222', mapTagsWithArticle)
139137
}
140138
}
141139
}

packages/crd-scripts/src/conf/webpack.config.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
66
const { defaultHTMLPath } = require('crd-utils')
77
const FriendlyErrorsWebpackPlugin = require('@nuxtjs/friendly-errors-webpack-plugin')
88
const { getDocsConfig } = require('crd-utils')
9-
const { getDirTree } = require('./getPrerenderRoutes')
9+
const { getDirTree } = require('./getDirTree')
1010
const config = require('./webpack.config')
1111
const paths = require('./path')
1212

packages/crd-scripts/src/conf/webpack.config.prod.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const { defaultHTMLPath, docsBuildDist } = require('crd-utils')
1212
const { getDocsConfig } = require('crd-utils')
1313
const config = require('./webpack.config')
1414
const paths = require('./path')
15-
const { getPrerenderRoutes, getDirTree } = require('./getPrerenderRoutes')
15+
const { getPrerenderRoutes } = require('./getPrerenderRoutes')
16+
const { getDirTree } = require('./getDirTree')
1617

1718
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
1819

0 commit comments

Comments
 (0)