forked from hannoeru/vite-plugin-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add remix style routing (hannoeru#169)
* feat: add remix style routing example * chore!: renamed nuxtStyle to routeStyle to support different naming conventions * fix: deps issue
- Loading branch information
Showing
41 changed files
with
842 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<p>features/admin/pages/admin.vue</p> | ||
<p>located in features/admin/pages folder</p> | ||
</template> | ||
|
||
<route> | ||
{ | ||
meta: { | ||
requiresAuth: false | ||
} | ||
} | ||
</route> |
12 changes: 12 additions & 0 deletions
12
examples/nuxt-style/src/features/dashboard/pages/dashboard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<p>features/dashboard/pages/dashboard.vue</p> | ||
<p>located in features/dashboard/pages folder</p> | ||
</template> | ||
|
||
<route> | ||
{ | ||
meta: { | ||
requiresAuth: true | ||
} | ||
} | ||
</route> |
12 changes: 12 additions & 0 deletions
12
examples/nuxt-style/src/features/dashboard/pages/welcome.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<p>features/dashboard/pages/welcome.vue</p> | ||
<p>located in features/dashboard/pages folder</p> | ||
</template> | ||
|
||
<route> | ||
{ | ||
meta: { | ||
requiresAuth: true | ||
} | ||
} | ||
</route> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "nodemon --watch ../../dist/*.js -x 'cross-env DEBUG=vite-plugin-pages:* vite'", | ||
"build": "cross-env DEBUG=vite-plugin-pages vite build", | ||
"serve": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-router-dom": "^6.2.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.39", | ||
"@types/react-dom": "^17.0.11", | ||
"@types/react-router-config": "^5.0.6", | ||
"@types/react-router-dom": "^5.3.3", | ||
"@vitejs/plugin-react": "^1.2.0", | ||
"cross-env": "^7.0.3", | ||
"nodemon": "^2.0.15", | ||
"typescript": "^4.5.5", | ||
"vite": "^2.8.2", | ||
"vite-plugin-pages": "workspace:*" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
monospace; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { | ||
useRoutes, | ||
BrowserRouter as Router, | ||
} from 'react-router-dom' | ||
|
||
import './index.css' | ||
|
||
import routes from '~react-pages' | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(routes) | ||
|
||
function App() { | ||
return useRoutes(routes) | ||
} | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<Router> | ||
<App /> | ||
</Router> | ||
</React.StrictMode>, | ||
document.getElementById('root'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
const all: React.FC = () => { | ||
return ( | ||
<p>...all route</p> | ||
) | ||
} | ||
|
||
export default all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
|
||
const Component: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>[sitemap.xml].tsx</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { Outlet } from 'react-router-dom' | ||
|
||
const Component: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>pathless layout route</p> | ||
<Outlet /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
|
||
const Component: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>__marketing/product.tsx</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<p>test default exclude</p> | ||
) | ||
} | ||
|
||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { Outlet } from 'react-router-dom' | ||
|
||
const Component: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>about layout route</p> | ||
<Outlet /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<p>about/index.tsx</p> | ||
) | ||
} | ||
|
||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
const Component: React.FC = () => { | ||
return ( | ||
<p>blog.authors.tsx</p> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import { Link, Outlet } from 'react-router-dom' | ||
|
||
const Blog: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>blog.tsx</p> | ||
<Link to="/blog/1b234bk12b3"> | ||
id: 1b234bk12b3 | ||
</Link> | | ||
<Link to="/blog/today"> | ||
today | ||
</Link> | | ||
<Link to="/blog/today/xxx"> | ||
not exists | ||
</Link> | ||
<Outlet /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Blog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
const all: React.FC = () => { | ||
return ( | ||
<p>blog ...all route</p> | ||
) | ||
} | ||
|
||
export default all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react' | ||
import { useParams } from 'react-router-dom' | ||
|
||
const Component: React.FC = () => { | ||
const { id } = useParams() | ||
return ( | ||
<> | ||
<p>blog/$id.tsx: { id }</p> | ||
</> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
|
||
const Component: React.FC = () => { | ||
return ( | ||
<> | ||
<p>blog/index.tsx</p> | ||
</> | ||
) | ||
} | ||
|
||
export default Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<p>blog/today/index.tsx</p> | ||
) | ||
} | ||
|
||
export default index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react' | ||
import { Link } from 'react-router-dom' | ||
|
||
const index: React.FC = () => { | ||
return ( | ||
<div> | ||
<p>index.tsx</p> | ||
<Link to="/blog"> | ||
blog | ||
</Link> | | ||
<Link to="/blog/authors"> | ||
blog authors | ||
</Link> | | ||
<Link to="/about"> | ||
about | ||
</Link> | | ||
<Link to="/product"> | ||
product | ||
</Link> | | ||
<Link to="/sitemap.xml"> | ||
sitemap.xml | ||
</Link> | | ||
<Link to="/xxx"> | ||
not exists | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default index |
Oops, something went wrong.