Skip to content

Commit

Permalink
docs: refactor Readme Component
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed May 22, 2022
1 parent 0c3113f commit 1d9b68e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"rules": {
"react/react-in-jsx-scope": 0
}
},
{
"files": "docs/*.tsx",
"rules": {
"@typescript-eslint/no-unsafe-return": 0
}
}
]
}
16 changes: 9 additions & 7 deletions docs/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ import {
useParams,
} from 'react-router-dom'

import Home from '../README.md'

import './global.css'
import 'github-markdown-css'

const Package = () => {
const Readme = () => {
const { name } = useParams<{ name: string }>()
const Pkg = lazy(() => import(`../packages/${name!}/README.md`))
const Readme = lazy(() =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
name ? import(`../packages/${name}/README.md`) : import('../README.md'),
)
return (
<Suspense>
<Pkg />
<Readme />
</Suspense>
)
}

const Changelog = () => {
const { name } = useParams<{ name: string }>()
const Changelog = lazy(() =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
name
? import(`../packages/${name}/CHANGELOG.md`)
: import('../CHANGELOG.md'),
Expand All @@ -44,15 +46,15 @@ export const App = () => (
/>
<Route
path="/packages/:name"
element={<Package />}
element={<Readme />}
/>
<Route
path="/packages/:name/CHANGELOG.md"
element={<Changelog />}
/>
<Route
path="/"
element={<Home />}
element={<Readme />}
/>
</Routes>
</Router>
Expand Down

0 comments on commit 1d9b68e

Please sign in to comment.