Skip to content

Commit 986a95a

Browse files
committed
feat: support default path for README
1 parent 0ce529a commit 986a95a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/更新日志.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ abbrlink: 179nqpxt
88

99
### 1.5.0
1010

11-
`2021-10-12`
11+
`2021-10-13`
1212

1313
- **Feature**
1414

packages/crd-seed/layout/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ function BasicLayout({
210210

211211
const carryRepoInProd = ifProd && repo
212212
const renderContent = () => {
213+
console.log('routeData', routeData)
214+
const defaultPath = (routeData.find(data => data.path === '/README')
215+
&& routeData.find(data => data.path === '/README').mdconf
216+
&& routeData.find(data => data.path === '/README').mdconf.abbrlink) || 'README'
213217
return (
214218
<div
215219
className={cx(`${styles.content}`, {
@@ -218,7 +222,7 @@ function BasicLayout({
218222
>
219223
<Switch>
220224
{/* see https://reacttraining.com/react-router/web/api/Redirect/exact-bool */}
221-
<Redirect exact from={ifAddPrefix ? `/${repo}` : `/`} to={ifAddPrefix ? `/${repo}/README` : `/README`} />
225+
<Redirect exact from={ifAddPrefix ? `/${repo}` : `/`} to={ifAddPrefix ? `/${repo}/${defaultPath}` : `/${defaultPath}`} />
222226
{routeData.map((item) => {
223227
const { path, mdconf, component } = item
224228
const { abbrlink } = mdconf

0 commit comments

Comments
 (0)