kitbagjs / router

A type safe router for vuejs
MIT License
131 stars 1 forks source link

Add `isRoute` type guard with `exact` option #183

Closed pleek91 closed 1 month ago

pleek91 commented 1 month ago

Description

The current route can be type guarded using useRoute('route.key'). Adding and isRoute type guard so that any value can be type guarded to determine A. If it is a RouterRoute B. Which user defined route it is

This allows for this type of logic

const route = useRoute()

if(isRoute(route, 'settings') {
  // do settings logic
}

if(isRoute(route, 'home') {
  // do home logic
}

There is also an optional 3rd argument for options where the exact option can be passed. Passing this settings means that if the current route is settings.foo then isRoute(route, 'settings', { exact: true }) will return false.

netlify[bot] commented 1 month ago

Deploy Preview for kitbag-router ready!

Name Link
Latest commit 61c57c9d3145a1603d78741964a266e1a2ab07a8
Latest deploy log https://app.netlify.com/sites/kitbag-router/deploys/665207c017c58a0008d39503
Deploy Preview https://deploy-preview-183--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.