Skip to content

Commit 5f31d24

Browse files
committed
feat: support config tags
1 parent 0a0acc1 commit 5f31d24

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ function directoryTree({
6262
mapTagsWithArticle = [],
6363
routePath = ''
6464
}) {
65-
const name = PATH.basename(path)
65+
const name = PATH.basename(path, '.md')
6666
const item = { name }
67-
const routePropsCurrent = `${routePath}/${name}`.replace(/.md$/, '')
67+
// const routePropsCurrent = `${routePath}/${name}`.replace(/.md$/, '')
68+
const routePropsCurrent = `${routePath}/${name}`
6869
if (!options.prerender) {
6970
item.path = path
7071
}

packages/crd-seed/component/Header/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Header = ({
1212
logo,
1313
}) => {
1414
// eslint-disable-next-line no-undef
15-
const { user, repo } = DOCSCONFIG || {}
15+
const { user, repo, tags } = DOCSCONFIG || {}
1616
const [checked, setChecked] = useState(false)
1717
const handleChange = (value) => {
1818
value
@@ -36,12 +36,16 @@ const Header = ({
3636
{DOCSCONFIG && DOCSCONFIG.search ? <Search className={styles.search} /> : null}
3737
</div>
3838
<div className={styles.rightArea}>
39-
<Link
40-
className={styles['tags']}
41-
to={ifProd ? `/${repo}/tags` : '/tags'}
42-
>
43-
标签
44-
</Link>
39+
{
40+
tags
41+
? <Link
42+
className={styles['tags']}
43+
to={ifProd ? `/${repo}/tags` : '/tags'}
44+
>
45+
标签
46+
</Link>
47+
: null
48+
}
4549
<Switch
4650
className={styles['no-dark-mode']}
4751
onChange={handleChange}

packages/crd-seed/layout/index.js

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ function BasicLayout({
2525
indexProps,
2626
}) {
2727
const { pathname } = location
28-
const { user, repo, branch = 'main', language = 'en', menuOpenKeys } = DOCSCONFIG || {}
28+
const {
29+
user,
30+
repo,
31+
branch = 'main',
32+
language = 'en',
33+
menuOpenKeys,
34+
tags
35+
} = DOCSCONFIG || {}
2936
const [inlineCollapsed, setInlineCollapsed] = useState(true)
3037
const [selectedKey, setSelectedKey] = useState('')
3138
const curOpenKeys = getOpenSubMenuKeys({
@@ -153,9 +160,10 @@ function BasicLayout({
153160
return pathname.indexOf(r.mdconf.abbrlink) > -1 || decodeURIComponent(pathname).indexOf(r.path) > -1
154161
})
155162
const editPathName = curMenuSource[0] && curMenuSource[0].props.path
163+
const isNotTagPage = location.pathname.indexOf('/tags') === -1
156164
return (
157165
<div className={cx(styles.pageHeader)}>
158-
{user && repo ? (
166+
{user && repo && isNotTagPage ? (
159167
<a
160168
href={`https://github.com/${user}/${
161169
repo
@@ -257,20 +265,26 @@ function BasicLayout({
257265
/>
258266
)
259267
})}
260-
<Route
261-
key='/tags'
262-
exact
263-
path={ifAddPrefix ? `/${repo}/tags` : '/tags'}
264-
render={() => <Tags />}
265-
/>
266-
<Route
267-
key='/tags/:name'
268-
path={ifAddPrefix ? `/${repo}/tags/:name` : '/tags/:name'}
269-
render={({ match }) => {
270-
const { name } = match.params
271-
return <Tags name={name} />
272-
}}
273-
/>
268+
{
269+
tags
270+
? <>
271+
<Route
272+
key='/tags'
273+
exact
274+
path={ifAddPrefix ? `/${repo}/tags` : '/tags'}
275+
render={() => <Tags />}
276+
/>
277+
<Route
278+
key='/tags/:name'
279+
path={ifAddPrefix ? `/${repo}/tags/:name` : '/tags/:name'}
280+
render={({ match }) => {
281+
const { name } = match.params
282+
return <Tags name={name} />
283+
}}
284+
/>
285+
</>
286+
: null
287+
}
274288
<Redirect to={ifAddPrefix ? `/${repo}/404` : `/404`} />
275289
</Switch>
276290
{renderPageFooter()}

0 commit comments

Comments
 (0)