-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add simpler example with unplugin-vue-router
- Loading branch information
1 parent
5542aa7
commit cae7638
Showing
27 changed files
with
435 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></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,24 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "nodemon --watch ../../dist/index.js -x \"cross-env DEBUG=vite-plugin-layouts vite\"", | ||
"build": "cross-env DEBUG=vite-plugin-layouts vite build", | ||
"serve": "vite preview" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.3.10" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^4.5.0", | ||
"@vue/compiler-sfc": "^3.3.8", | ||
"cross-env": "^7.0.3", | ||
"nodemon": "^3.0.1", | ||
"typescript": "^5.3.2", | ||
"vite": "^5.0.2", | ||
"vite-plugin-inspect": "^0.8.1", | ||
"vite-plugin-pages": "^0.32.0", | ||
"vite-plugin-vue-layouts": "workspace:*", | ||
"unplugin-vue-markdown": "^0.25.2", | ||
"unplugin-vue-router": "^0.7.0" | ||
} | ||
} |
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,3 @@ | ||
<template> | ||
<router-view /> | ||
</template> |
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 @@ | ||
.test { } |
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,8 @@ | ||
<template> | ||
<main class="px-4 py-10 text-center text-gray-700 dark:text-gray-200"> | ||
<div class="w-1/4 m-auto text-center text-gray-300 bg-teal-800"> | ||
Default Layout | ||
</div> | ||
<router-view /> | ||
</main> | ||
</template> |
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,8 @@ | ||
<template> | ||
<main class="px-4 py-10 text-center text-gray-700 dark:text-gray-200"> | ||
<div class="w-1/4 m-auto text-center text-gray-300 bg-teal-800"> | ||
Second Layout | ||
</div> | ||
<router-view /> | ||
</main> | ||
</template> |
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,8 @@ | ||
<template> | ||
<main class="px-4 py-10 text-center text-gray-700 dark:text-gray-200"> | ||
<div class="w-1/4 m-auto text-center text-gray-300 bg-teal-800"> | ||
Layout Sub Folder | ||
</div> | ||
<router-view /> | ||
</main> | ||
</template> |
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,19 @@ | ||
import { createApp } from 'vue' | ||
import { createRouter, createWebHistory } from 'vue-router/auto' | ||
import { createGetRoutes, setupLayouts } from 'virtual:generated-layouts' | ||
import App from './App.vue' | ||
import './index.css' | ||
|
||
const router = createRouter({ | ||
history: createWebHistory(), | ||
extendRoutes: routes => setupLayouts(routes), | ||
}) | ||
|
||
const getRoutes = createGetRoutes(router) | ||
console.log(getRoutes()) | ||
|
||
const app = createApp(App) | ||
|
||
app.use(router) | ||
|
||
app.mount('#app') |
8 changes: 8 additions & 0 deletions
8
examples/unplugin-vue-router/src/module1/layouts/module1layout.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,8 @@ | ||
<template> | ||
<main class="px-4 py-10 text-center text-gray-700 dark:text-gray-200"> | ||
<div class="w-1/4 m-auto text-center text-gray-300 bg-teal-800"> | ||
Module 1 Layout | ||
</div> | ||
<router-view /> | ||
</main> | ||
</template> |
8 changes: 8 additions & 0 deletions
8
examples/unplugin-vue-router/src/module2/layouts/module2layout.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,8 @@ | ||
<template> | ||
<main class="px-4 py-10 text-center text-gray-700 dark:text-gray-200"> | ||
<div class="w-1/4 m-auto text-center text-gray-300 bg-teal-800"> | ||
Module 2 Layout | ||
</div> | ||
<router-view /> | ||
</main> | ||
</template> |
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,6 @@ | ||
<template> | ||
<p>/about/index.vue</p> | ||
<router-link to="/about/who/me"> | ||
me | ||
</router-link> | ||
</template> |
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>meeeeee</p> | ||
</template> | ||
|
||
<route> | ||
{ | ||
name: "who-me-override", | ||
meta: { | ||
requiresAuth: false | ||
} | ||
} | ||
</route> |
3 changes: 3 additions & 0 deletions
3
examples/unplugin-vue-router/src/pages/deep/deeper/deepest/index.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,3 @@ | ||
<template> | ||
<div>Deepest Sub folder page with no layout set, should use default</div> | ||
</template> |
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,6 @@ | ||
<template> | ||
<div> | ||
Deeper Sub folder page with no layout set, should use default | ||
<p><router-link to="/deep/deeper/deepest">Go Deepest</router-link></p> | ||
</div> | ||
</template> |
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,6 @@ | ||
<template> | ||
<div> | ||
Sub folder page with no layout set, should use default | ||
<p><router-link to="/deep/deeper">Go Deeper</router-link></p> | ||
</div> | ||
</template> |
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,39 @@ | ||
<template> | ||
<div> | ||
<p>index.vue</p> | ||
<router-link to="/about"> about </router-link> | ||
<p> | ||
<router-link to="/news"> news </router-link> | | ||
<router-link :to="{ name: 'named-news-page' }"> | ||
today's news | ||
</router-link> | ||
</p> | ||
<p> | ||
<router-link to="/sublayout"> sub layout </router-link> | ||
</p> | ||
<p> | ||
<router-link to="/nolayout"> no layout </router-link> | ||
</p> | ||
<p> | ||
<router-link to="/module1"> module 1 layout </router-link> | ||
</p> | ||
<p> | ||
<router-link to="/module2"> module 2 layout </router-link> | ||
</p> | ||
<p> | ||
<router-link to="/second"> second level layout </router-link> | ||
</p> | ||
<p> | ||
<router-link to="/deep"> | ||
deep sub folder with no layout specified | ||
</router-link> | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<route> | ||
{ | ||
name: "name-override", | ||
meta: {requiresAuth: false} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div>Module 1 Content</div> | ||
</template> | ||
<route> | ||
{ | ||
meta: { | ||
layout: "module1layout" | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div>Module 2 Content</div> | ||
</template> | ||
<route> | ||
{ | ||
meta: { | ||
layout: "module2layout" | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<router-view /> | ||
</template> | ||
<route> | ||
{ | ||
meta: { | ||
layout: "second" | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template> | ||
<p>/news/today.vue</p> | ||
</template> | ||
<route> | ||
{ | ||
name: 'named-news-page' | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<p>/news/index.vue</p> | ||
</template> |
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,10 @@ | ||
<template> | ||
<div> | ||
<p>nolayout</p> | ||
</div> | ||
</template> | ||
|
||
<route lang="yaml"> | ||
meta: | ||
layout: false | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<div> | ||
Second level layout. | ||
<router-view /> | ||
</div> | ||
</template> | ||
<route> | ||
{ | ||
meta: { | ||
layout: "second" | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<div> | ||
<p>sublayout</p> | ||
</div> | ||
</template> | ||
|
||
<route> | ||
{meta: { | ||
layout: "sub/layoutsub" | ||
} | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module '*.vue' { | ||
import type { DefineComponent } from 'vue' | ||
const component: DefineComponent<{}, {}, any> | ||
export default component | ||
} |
Oops, something went wrong.