File tree Expand file tree Collapse file tree 7 files changed +30
-47
lines changed Expand file tree Collapse file tree 7 files changed +30
-47
lines changed Original file line number Diff line number Diff line change 3434 "react" : " ^18.2.0" ,
3535 "react-dom" : " ^18.2.0" ,
3636 "react-redux" : " ~7.2.6" ,
37- "react-router-dom" : " ^6.3 .0" ,
37+ "react-router-dom" : " ^6.14 .0" ,
3838 "rehype-rewrite" : " ^3.0.6" ,
3939 "rehype-video" : " ^1.2.2" ,
4040 "uiw" : " ~4.21.19"
Original file line number Diff line number Diff line change @@ -19,21 +19,21 @@ export default function Search() {
1919 to : '/pkg/uiw' ,
2020 label : 'uiw' ,
2121 } ,
22- {
23- to : '/pkg/vue' ,
24- label : 'vue' ,
25- } ,
2622 {
2723 to : '/pkg/react' ,
2824 label : 'react' ,
2925 } ,
3026 {
31- to : '/pkg/react@17' ,
32- label : 'react@17' ,
27+ to : '/pkg/vue' ,
28+ label : 'vue' ,
29+ } ,
30+ {
31+ to : '/pkg/react@18' ,
32+ label : 'react@18' ,
3333 } ,
3434 {
35- to : '/pkg/react@17.0.1 ' ,
36- label : 'react@17.0.1 ' ,
35+ to : '/pkg/react@18.2.0 ' ,
36+ label : 'react@18.2.0 ' ,
3737 } ,
3838 ] ) ;
3939 const name = pkg && pkg . name ? `${ pkg . name } @${ pkg . version } ` : pkgname ;
Original file line number Diff line number Diff line change 1- import { Suspense } from 'react' ;
21import { createRoot } from 'react-dom/client' ;
32import { Provider } from 'react-redux' ;
43import Loader from '@uiw/react-loader' ;
5- import { HashRouter , Route , Routes } from 'react-router-dom' ;
64import GitHubCorners from '@uiw/react-github-corners' ;
5+ import { RouterProvider , createHashRouter } from 'react-router-dom' ;
76import '@uiw/reset.css' ;
87import { store } from './models' ;
98import './index.css' ;
109import { routes } from './routers' ;
1110
12- const Loading = (
11+ const Loading = ( ) => (
1312 < div style = { { padding : 30 } } >
1413 < Loader tip = "loading..." />
1514 </ div >
1615) ;
1716
18- function App ( ) {
19- return (
20- < HashRouter >
21- < Routes >
22- { routes . map ( ( { element : Child , path } , idx ) => {
23- const Com = Child as any ;
24- return (
25- < Route
26- key = { idx }
27- path = { path }
28- element = {
29- < Suspense fallback = { Loading } >
30- < Com />
31- </ Suspense >
32- }
33- />
34- ) ;
35- } ) }
36- </ Routes >
37- </ HashRouter >
38- ) ;
39- }
40-
4117const container = document . getElementById ( 'root' ) ;
4218const root = createRoot ( container ! ) ;
4319
4420root . render (
4521 < Provider store = { store } >
4622 < GitHubCorners size = { 54 } target = "_parent" href = "https://github.com/uiwjs/npm-unpkg" />
47- < App />
23+ < RouterProvider router = { createHashRouter ( routes ) } fallbackElement = { < Loading /> } />
4824 </ Provider >
4925) ;
Original file line number Diff line number Diff line change 11import Search from '../../components/Search' ;
22import styles from './index.module.less' ;
33
4- export default function Home ( ) {
4+ export function Component ( ) {
55 return (
66 < div className = { styles . content } >
7- < h1 > npm unpkg </ h1 >
7+ < h1 > NPM UNPKG </ h1 >
88 < Search />
99 </ div >
1010 ) ;
1111}
12+
13+ Component . displayName = 'HomePage' ;
Original file line number Diff line number Diff line change 3434 background-color : var (--color-fg-subtle );
3535 margin-top : 2px ;
3636 }
37+ .unpkg {
38+ text-decoration : none ;
39+ font-weight : 900 ;
40+ }
3741}
3842
3943:global(.w-layout ) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import styles from './index.module.less';
1919
2020const { Header, Content } = Layout ;
2121
22- export default function Preview ( ) {
22+ export function Component ( ) {
2323 const {
2424 showSearch,
2525 notFindPkg,
@@ -67,8 +67,8 @@ export default function Preview() {
6767
6868 const unPkgView = useMemo (
6969 ( ) => (
70- < a href = { `https://unpkg.com/browse/${ path . pkgName } /` } target = "__blank" >
71- unpkg
70+ < a className = { styles . unpkg } href = { `https://unpkg.com/browse/${ path . pkgName } /` } target = "__blank" >
71+ UNPKG
7272 </ a >
7373 ) ,
7474 [ path . pkgName ] ,
@@ -157,3 +157,5 @@ export default function Preview() {
157157 </ Layout >
158158 ) ;
159159}
160+
161+ Component . displayName = 'PreviewPage' ;
Original file line number Diff line number Diff line change 1- import React , { lazy } from 'react' ;
21import { RouteObject } from 'react-router-dom' ;
32
43export const routes : RouteObject [ ] = [
54 {
65 path : '/' ,
7- element : lazy ( ( ) => import ( './pages/Home' ) ) as unknown as React . ReactNode ,
6+ lazy : ( ) => import ( './pages/Home' ) ,
87 } ,
98 {
109 path : '/pkg/:name' ,
11- element : lazy ( ( ) => import ( './pages/Preview' ) ) as unknown as React . ReactNode ,
10+ lazy : ( ) => import ( './pages/Preview' ) ,
1211 } ,
1312 {
1413 path : '/pkg/:name/file/:filename/*' ,
15- element : lazy ( ( ) => import ( './pages/Preview' ) ) as unknown as React . ReactNode ,
14+ lazy : ( ) => import ( './pages/Preview' ) ,
1615 } ,
1716 {
1817 path : '/pkg/:org/:name' ,
19- element : lazy ( ( ) => import ( './pages/Preview' ) ) as unknown as React . ReactNode ,
18+ lazy : ( ) => import ( './pages/Preview' ) ,
2019 } ,
2120 {
2221 path : '/pkg/:org/:name/file/:filename/*' ,
23- element : lazy ( ( ) => import ( './pages/Preview' ) ) as unknown as React . ReactNode ,
22+ lazy : ( ) => import ( './pages/Preview' ) ,
2423 } ,
2524] ;
You can’t perform that action at this time.
0 commit comments