This repository was archived by the owner on Feb 24, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 113
Add experimental custom resolver #700
Merged
Merged
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
b744abb
feat: add new experimental option
posva fe9da99
feat: support static paths for resolver
posva 8e0a7a2
refactor: missing import type
posva f4ad320
chore: remove baseUrl from tsconfig
posva 81e088e
chore: add experimental playground
posva 8a6cbb3
chore: fix name in layout
posva 672b160
feat: sorting of experimental resolver
posva 613fa62
feat: parse custom param
posva 3cbe471
chore: custom param in playground
posva 2ab8dad
feat: types + runtime of param parsers on path
posva 6c65c9e
refactor: simplify options by placing them in tree
posva 914908b
feat: support custom params folder
posva 53209aa
refactor: rename import as
posva 928e6f3
refactor: fixes
posva 3cc9afa
chore: fix package install
posva 0638535
ci: update packages
posva 4adf69a
refactor: place sub segments
posva 8e255e4
fix: handle subsegments
posva be601e2
chore: up vue router
posva 246106d
fix: non greedy param
posva b4fe703
fix: proper scoring
posva 3171dfe
feat: remove empty parents from routes
posva 77275d7
chore: rename to test 404 page
posva 5f95cde
chore: add meta to page
posva 2d10fcf
feat: support meta properties
posva 2b2a0fd
style: fix code style
autofix-ci[bot] 43ef24c
Update src/codegen/generateParamParsers.ts
posva 54eb0a9
chore: delete unused file
posva b07c37a
chore: simplify playground
posva 4e12c2f
chore: todo in editable tree
posva f97c011
refactor: glob for param parsers
posva 9630947
fix: escape regex in paths
posva be007b1
chore: import from node:fs
posva 30e8455
chore: unused import'
posva c50eddd
chore: unused error
posva 24ca324
refactor: simpler merge
posva 3788f5e
fix: types in helper
posva b7b4ed8
chore: fix __dirname usage
posva d511a60
chore
posva c692ef2
chore: color scheme
posva 30ec654
refactor: miss in date param parser
posva c2c702f
chore: update vue router usage
posva 91e1bcb
feat: handle splats
posva 892932f
chore: playground ts
posva 836b0f0
refactor: no use of fs watcher internal
posva 5a12ed9
refactor: up vue-router
posva bf0fc9c
chore: rename
posva 408cf87
chore: typo
posva 34cebfa
refactor: improve type for param parsers
posva 04255a5
refactor: rename paramMatchers to paramParsers
posva 97e2163
chore: wrong imports
posva 96f0c8e
chore: rename not found in playground
posva 5a44c0a
chore: inline
posva a6d23dd
feat: extract param parsers from definePage
posva 2a41d6e
chore: remov efor merge
posva 1fa44b1
feat: handle query types
posva d01d990
chore: simpler check
posva c920045
feat: remove 'both' format for query params, default to 'value'
posva 6fdf414
chore: bold
posva c879999
refactor: rename var
posva 3b76a48
chore: typo
posva 6375f51
chore: update vr syntax
posva 6ff699b
refactor: adapt to new version
posva 1c764aa
test: todo
posva 83133aa
refactor: native parsers
posva bb72cff
test: tests
posva 5aa298a
fix: setup watchers only when needed
posva b6dab9a
feat: handle negative default querya params
posva c03a6e5
fix: pass null to splat params
posva 8d4beef
chore: simplify warn
posva ba060fa
feat: ensure consistent non trailing slash
posva 1a9cdb2
test: layouts
posva 191b454
test: improve tests for regexp
posva b54ec25
test: typo
posva 067d3ef
refactor: simplify branch
posva c195442
chore: up router
posva f463ebf
feat: allow function in default
posva 060a79a
refactor: remove deprecated method
posva 2bb43d4
chore: up vue-macros
posva 5615002
feat: type custom params
posva 8366aae
chore: up deps
posva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| tsconfig.tsbuildinfo |
This file contains hidden or 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,14 @@ | ||
| /* eslint-disable */ | ||
| /* prettier-ignore */ | ||
| // @ts-nocheck | ||
| // noinspection JSUnusedGlobalSymbols | ||
| // Generated by unplugin-auto-import | ||
| // biome-ignore lint: disable | ||
| export {} | ||
| declare global { | ||
| const defineBasicLoader: typeof import('../src/data-loaders/entries/basic')['defineBasicLoader'] | ||
| const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave'] | ||
| const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate'] | ||
| const useRoute: typeof import('vue-router')['useRoute'] | ||
| const useRouter: typeof import('vue-router')['useRouter'] | ||
| } |
This file contains hidden or 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 @@ | ||
| { | ||
| "todos": [ | ||
| { | ||
| "id": 2, | ||
| "title": "Walking", | ||
| "completed": true | ||
| }, | ||
| { | ||
| "id": 3, | ||
| "title": "Cleaning", | ||
| "completed": false | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "title": "Cooking", | ||
| "completed": true | ||
| }, | ||
| { | ||
| "title": "hello", | ||
| "completed": false, | ||
| "id": 7 | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,2 @@ | ||
| /// <reference types="vite/client" /> | ||
| /// <reference types="unplugin-vue-router/client" /> |
This file contains hidden or 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 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| </head> | ||
| <style> | ||
| :root { | ||
| color-scheme: light dark; | ||
| } | ||
| </style> | ||
| <body> | ||
| <a | ||
| href="/__inspect/#/module?id=/__vue-router/auto-routes&index=0" | ||
| target="_blank" | ||
| style="margin-top: 10px; display: block" | ||
| >visit /__inspect/ to inspect the intermediate state</a | ||
| > | ||
| <div id="app"></div> | ||
| <script type="module" src="./src/main.ts"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,23 @@ | ||
| { | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "nodemon -w '../src/**/*.ts' -e .ts -x vite", | ||
| "json-server": "json-server --watch db.json --port 4000", | ||
| "playground:build": "vite build" | ||
| }, | ||
| "devDependencies": { | ||
| "@vitejs/plugin-vue": "^6.0.1", | ||
| "@vue/compiler-sfc": "^3.5.18", | ||
| "@vue/tsconfig": "^0.7.0", | ||
| "json-server": "^0.17.4", | ||
| "unplugin-vue-router": "workspace:*", | ||
| "vite": "^7.1.2" | ||
| }, | ||
| "dependencies": { | ||
| "mande": "^2.0.9", | ||
| "pinia": "^3.0.3", | ||
| "vue": "^3.5.18", | ||
| "vue-router": "https://pkg.pr.new/vue-router@4f1a37a" | ||
| } | ||
| } | ||
This file contains hidden or 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,72 @@ | ||
| <script setup lang="ts"> | ||
| import { ref } from 'vue' | ||
|
|
||
| const router = useRouter() | ||
|
|
||
| console.log(`We have ${router.getRoutes().length} routes.`) | ||
|
|
||
| const targetRoute = ref('') | ||
| </script> | ||
|
|
||
| <template> | ||
| <header> | ||
| <div class="wrapper"> | ||
| <nav> | ||
| <ul> | ||
| <li> | ||
| <RouterLink to="/">Home</RouterLink> | ||
| </li> | ||
| <li> | ||
| <RouterLink to="/users/24" #default="{ href }">{{ | ||
| href | ||
| }}</RouterLink> | ||
| </li> | ||
| <li> | ||
| <RouterLink to="/events/1992-03-24" #default="{ href }">{{ | ||
| href | ||
| }}</RouterLink> | ||
| </li> | ||
| </ul> | ||
| </nav> | ||
| </div> | ||
|
|
||
| <div> | ||
| <p>Currently at "{{ $route.name }}" ({{ $route.fullPath }})</p> | ||
| <pre>{{ $route.params }}</pre> | ||
| <form @submit.prevent="router.push(targetRoute)"> | ||
| <label> | ||
| Navigate to: | ||
| <input type="text" v-model="targetRoute" /> | ||
| </label> | ||
| <button>Go</button> | ||
| </form> | ||
| </div> | ||
| </header> | ||
|
|
||
| <hr /> | ||
|
|
||
| <RouterView /> | ||
| <hr /> | ||
| <RouterView name="named" /> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| ul { | ||
| padding-left: 0; | ||
| } | ||
| ul > li { | ||
| display: inline-block; | ||
| } | ||
|
|
||
| ul > li:not(:first-child) { | ||
| margin-left: 0.5rem; | ||
| } | ||
|
|
||
| li > a { | ||
| text-decoration: none; | ||
| } | ||
| .router-link-active { | ||
| text-decoration: underline; | ||
| font-weight: bold; | ||
| } | ||
| </style> |
This file contains hidden or 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,29 @@ | ||
| import { createApp } from 'vue' | ||
| import App from './App.vue' | ||
| import { createPinia } from 'pinia' | ||
| import { PiniaColada } from '@pinia/colada' | ||
| import { router } from './router' | ||
| import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders' | ||
| import { RouterLink, RouterView } from 'vue-router' | ||
|
|
||
| const app = createApp(App) | ||
|
|
||
| app.use(createPinia()) | ||
| app.use(PiniaColada, {}) | ||
| // @ts-expect-error: FIXME: should be doable | ||
| app.use(DataLoaderPlugin, { router }) | ||
| app.component('RouterLink', RouterLink) | ||
| app.component('RouterView', RouterView) | ||
| app.use(router) | ||
|
|
||
| // @ts-expect-error: for debugging on browser | ||
| window.$router = router | ||
posva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| app.mount('#app') | ||
|
|
||
| // small logger for navigations, useful to check HMR | ||
| router.isReady().then(() => { | ||
| router.beforeEach((to, from) => { | ||
| console.log('🧭', from.fullPath, '->', to.fullPath) | ||
| }) | ||
| }) | ||
This file contains hidden or 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 @@ | ||
| <script lang="ts" setup></script> | ||
|
|
||
| <template> | ||
| <h1>Page outside of <code>pages</code></h1> | ||
| </template> |
This file contains hidden or 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,7 @@ | ||
| <script lang="ts" setup></script> | ||
|
|
||
| <template> | ||
| <h1>Home</h1> | ||
|
|
||
| <p>This is the homepage.</p> | ||
| </template> |
This file contains hidden or 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,71 @@ | ||
| <script setup lang="ts"> | ||
| import doc from '../main.ts?raw' | ||
|
|
||
| const route = useRoute() | ||
posva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const router = useRouter() | ||
| route.params.path | ||
|
|
||
| console.log('typeof', typeof route.params.active) | ||
| console.log('value', route.params.active) | ||
| console.log('typeof', typeof route.params.other) | ||
| console.log('value', route.params.other) | ||
posva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| definePage({ | ||
| meta: { | ||
| title: 'Not Found', | ||
| description: 'This page does not exist.', | ||
| docLength: doc.length, | ||
| number: 27, | ||
| }, | ||
| name: 'not-found', | ||
| params: { | ||
| query: { | ||
| page: { | ||
| parser: 'int', | ||
| default: 1, | ||
| format: 'value', | ||
| }, | ||
| other: { | ||
| parser: 'bool', | ||
| default: false, | ||
| }, | ||
| active: { | ||
| parser: 'bool', | ||
| default: true, | ||
| }, | ||
|
|
||
| multi: { | ||
| format: 'array', | ||
| }, | ||
|
|
||
| req: { | ||
| parser: 'int', | ||
| default: -1, | ||
| }, | ||
|
|
||
| when: { | ||
| parser: 'date', | ||
| default: () => new Date(), | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <main> | ||
| <h1>Not Found</h1> | ||
|
|
||
| <pre>{{ $route.params }}</pre> | ||
| <pre>{{ $route.query }}</pre> | ||
| <pre>{{ $route.meta }}</pre> | ||
| </main> | ||
| </template> | ||
|
|
||
| <route lang="json"> | ||
| { | ||
| "meta": { | ||
| "from block": true | ||
| } | ||
| } | ||
| </route> | ||
This file contains hidden or 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 @@ | ||
| <script lang="ts" setup></script> | ||
|
|
||
| <template> | ||
| <h1>{{ String($route.name) }} - {{ $route.path }}</h1> | ||
| </template> |
This file contains hidden or 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 @@ | ||
| <script lang="ts" setup></script> | ||
|
|
||
| <template> | ||
| <h1>Page B</h1> | ||
| </template> |
This file contains hidden or 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,7 @@ | ||
| <script lang="ts" setup></script> | ||
|
|
||
| <template> | ||
| <h1>Blog</h1> | ||
|
|
||
| <pre>{{ $route.params }}</pre> | ||
| </template> |
This file contains hidden or 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,7 @@ | ||
| <script lang="ts" setup></script> | ||
|
|
||
| <template> | ||
| <h1>Blog</h1> | ||
|
|
||
| <pre>{{ $route.params }}</pre> | ||
| </template> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.