Skip to content

Commit 54291d5

Browse files
committed
fix: update generate sitemap
1 parent 933d72e commit 54291d5

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ const getDirTree = (cmd) => {
1212
path,
1313
options: otherProps,
1414
}))
15+
// console.log('dirTree', dirTree)
1516
return dirTree
1617
}
1718

1819
// eg: ['docs/quick_start.md', 'a']
1920
// output: ['/quick_start', '/a/b', '/a/b/c']
2021
const getPrerenderRoutes = (dirTree) => {
21-
const result = getPrerenderRoute(dirTree)
22+
const dpCloneDirTree = JSON.parse(JSON.stringify(dirTree))
23+
const result = getPrerenderRoute(dpCloneDirTree)
2224
result.push('/404')
2325
return result
2426
}
@@ -36,8 +38,8 @@ function recursive(data, routePath, arr) {
3638

3739
if (item.type === 'directory') {
3840
if (item.children && item.children.length > 0) {
39-
// eslint-disable-next-line no-unused-vars
40-
item.children = recursive(item.children, composeRouteName, arr)
41+
// todo: judge if use deep clone to isolate them.
42+
// item.children = recursive(item.children, composeRouteName, arr)
4143
} else {
4244
item.children = []
4345
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function directoryTree({
125125
}
126126
} else if (stats.isDirectory()) {
127127
const dirData = safeReadDirSync(path)
128+
console.log('dirData', dirData)
128129
if (dirData === null) return null
129130
item.children = dirData
130131
.map(child =>
@@ -134,7 +135,6 @@ function directoryTree({
134135
}),
135136
)
136137
.filter(e => !!e)
137-
console.log('item.children', item.children)
138138
item.type = constants.DIRECTORY
139139
if (!options.prerender) {
140140
item.size = item.children.reduce((prev, cur) => prev + cur.size, 0)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = function (cmd) {
2020
const docsConfig = getDocsConfig()
2121
const dirTree = getDirTree(cmd)
2222
const routes = getPrerenderRoutes(dirTree)
23-
console.log('dirTree', dirTree)
2423

2524
config.mode = 'production'
2625
config.entry = [paths.appIndexJs]
@@ -29,6 +28,8 @@ module.exports = function (cmd) {
2928
config.output.publicPath = docsConfig.repo ? `/${docsConfig.repo}/` : '/'
3029
config.output.path = docsConfig.repo ? `${docsBuildDist}/${docsConfig.repo}` : docsBuildDist
3130

31+
console.log('dirTree12345', dirTree)
32+
3233
config.module.rules = config.module.rules.map((item) => {
3334
if (item.oneOf) {
3435
const loaders = []
@@ -172,7 +173,9 @@ module.exports = function (cmd) {
172173
// move README as root index.html
173174
// todo: replace README with correct path
174175

175-
176+
const defaultPath = (dirTree.find(data => data.name === 'README.md')
177+
&& dirTree.find(data => data.name === 'README.md').mdconf
178+
&& dirTree.find(data => data.name === 'README.md').mdconf.abbrlink) || 'README'
176179

177180

178181
await fs.copy(`${docsBuildDist}/README/index.html`, `${docsBuildDist}/index.html`)

0 commit comments

Comments
 (0)