From 541a802fef505203a597a683cea58f3c7f5b3f06 Mon Sep 17 00:00:00 2001 From: xjccc <546534045@qq.com> Date: Mon, 5 Feb 2024 04:52:21 +0800 Subject: [PATCH] docs: explain how to set `` defaults in nuxt config (#25610) --- docs/3.api/1.components/4.nuxt-link.md | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/3.api/1.components/4.nuxt-link.md b/docs/3.api/1.components/4.nuxt-link.md index eda9da9757..83bbff0950 100644 --- a/docs/3.api/1.components/4.nuxt-link.md +++ b/docs/3.api/1.components/4.nuxt-link.md @@ -116,6 +116,34 @@ Defaults can be overwritten, see [overwriting defaults](#overwriting-defaults) i ## Overwriting Defaults +### In Nuxt Config + +You can overwrite some `` defaults in your [`nuxt.config`](https://nuxt.com/docs/api/nuxt-config#defaults) + +::callout{color="amber" icon="i-ph-warning-duotone"} +These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory. +:: + +```ts [nuxt.config.ts] +export default defineNuxtConfig({ + experimental: { + defaults: { + nuxtLink: { + // default values + componentName: 'NuxtLink', + externalRelAttribute: 'noopener noreferrer', + activeClass: 'router-link-active', + exactActiveClass: 'router-link-exact-active', + prefetchedClass: undefined, // can be any valid string class name + trailingSlash: undefined // can be 'append' or 'remove' + } + } + } +}) +``` + +### Custom Link Component + You can overwrite `` defaults by creating your own link component using `defineNuxtLink`. ```js [components/MyNuxtLink.ts]