-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from victorgarciaesgi/feat/3.4.0
v3.4.0
- Loading branch information
Showing
29 changed files
with
4,793 additions
and
9,031 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
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,56 @@ | ||
--- | ||
title: Typing component props | ||
--- | ||
|
||
# NuxtLink | ||
|
||
|
||
Sometimes you don't want to use `NuxtLink` directly and make a wrapper component, there is a way to do it with `nuxt-typed-router`. It implies using component generics if you're on a Vue SFC | ||
|
||
```vue | ||
<template> | ||
<NuxtLink :to="props.to"></NuxtLink> | ||
</template> | ||
<script setup lang="ts" generic="T extends RoutesNamesList, P extends string"> | ||
import type { RoutesNamesList, NuxtRoute } from '@typed-router'; | ||
const props = defineProps<{ | ||
to: NuxtRoute<T, P>; | ||
}>(); | ||
</script> | ||
``` | ||
|
||
It's also easy to add support for `external` prop | ||
|
||
```vue | ||
<template> | ||
<NuxtLink :to="props.to" :external='props.external'></NuxtLink> | ||
</template> | ||
<script setup lang="ts" generic="T extends RoutesNamesList, P extends string, E extends boolean = false"> | ||
import type { RoutesNamesList, NuxtRoute } from '@typed-router'; | ||
const props = defineProps<{ | ||
to: NuxtRoute<T, P>, | ||
external?: E, | ||
}>(); | ||
</script> | ||
``` | ||
|
||
## Same behaviour for pure Typescript functions | ||
|
||
|
||
```ts | ||
import type { RoutesNamesList, NuxtRoute } from '@typed-router'; | ||
|
||
export function myCustomNavigateTool<T extends RoutesNamesList, P extends string>(to: NuxtRoute<T, P>) { | ||
// | ||
} | ||
|
||
``` | ||
|
||
|
||
::alert{type="info"} | ||
There is also the same type variant if you use `@nuxtjs/i18n` : `NuxtLocaleRoute` | ||
:: |
4 changes: 2 additions & 2 deletions
4
...3.options/3.experimentalRemoveNuxtDefs.md → docs/content/3.options/3.removeNuxtDefs.md
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
6 changes: 3 additions & 3 deletions
6
...t/3.options/4.experimentalIgnoreRoutes.md → docs/content/3.options/4.ignoreRoutes.md
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 |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
}, | ||
"devDependencies": { | ||
"@nuxt-themes/docus": "1.14.3", | ||
"nuxt": "^3.8.1" | ||
"nuxt": "3.8.1" | ||
} | ||
} |
Oops, something went wrong.