kitbagjs / router

A type safe router for vuejs
https://router.kitbag.dev
MIT License
173 stars 4 forks source link

remove disabled concept #233

Closed stackoverfloweth closed 2 months ago

stackoverfloweth commented 2 months ago

with the latest iteration of defining routes we can now define parent routes and choose to not include them when calling createRouter. This effectively does the task of what "disabled" did previously but in a more straight forward and hopefully obvious way to our developers.

Currently, kitbag router lets you set a route as "disabled". A disabled route still effects the children, passing down params, path, query, host, and key but a disabled route can never be matched. So end users cannot create a router-link to a disabled route or navigate with router.push to a disabled route.

const routes = createRoutes([
  { name: 'parent', disabled: true, children: createRoutes([
    { name: 'foo', component: ... },
    { name: 'bar', component: ... },
  ])
])

const router = createRouter(routes)

With our new syntax createRoute, we can still create the parent route and assign as a parent but omit from our routes when calling createRouter.

const parent = createRoute({ name: 'parent' })

const routes = [
  createRoute({ parent, name: 'foo', component: ... }),
  createRoute({ parent, name: 'bar', component: ... },)
] as const

const router = createRouter(routes)
netlify[bot] commented 2 months ago

Deploy Preview for kitbag-router ready!

Name Link
Latest commit 0b67eb2d2e264e4f9f895e3975d153c28eb43780
Latest deploy log https://app.netlify.com/sites/kitbag-router/deploys/66a3056bba58b000088e75f3
Deploy Preview https://deploy-preview-233--kitbag-router.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.