Páginas Links
Una lista de enlaces que se mostrarán en la página.
xph0000xUso
Utilice el componente PageLinks para mostrar una lista de enlaces.
<script setup lang="ts">
import type { PageLink } from '@nuxt/ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui/blob/v4/docs/content/docs/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}
])
</script>
<template>
<UPageLinks :links="links" />
</template><script setup lang="ts">
import { ref } from 'vue'
import type { PageLink } from '@nuxt/ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui/blob/v4/docs/content/docs/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}
])
</script>
<template>
<UPageLinks :links="links" />
</template>Enlaces
Utilice el prop links como una matriz de objetos con las siguientes propiedades:
- xx
label: stringxx{lang="ts-type"} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - xx
class?: anyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - xxx
ui?: { item?: ClassNameValue, link?: ClassNameValue, linkLabel?: ClassNameValue, linkLabelExternalIcon?: ClassNameValue, linkLeadingIcon?: ClassNameValue }xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Puede pasar cualquier propiedad del componente Link como to, target, etc.
<script setup lang="ts">
import type { PageLink } from '@nuxt/ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui/blob/v4/docs/content/docs/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}
])
</script>
<template>
<UPageLinks :links="links" />
</template><script setup lang="ts">
import { ref } from 'vue'
import type { PageLink } from '@nuxt/ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui/blob/v4/docs/content/docs/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}
])
</script>
<template>
<UPageLinks :links="links" />
</template>Nombre
Utilice el prop title para mostrar un título encima de los enlaces.
<script setup lang="ts">
import type { PageLink } from '@nuxt/ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui/blob/v4/docs/content/docs/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}
])
</script>
<template>
<UPageLinks title="Community" :links="links" />
</template><script setup lang="ts">
import { ref } from 'vue'
import type { PageLink } from '@nuxt/ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui/blob/v4/docs/content/docs/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}
])
</script>
<template>
<UPageLinks title="Community" :links="links" />
</template>Ejemplos
Si bien estos ejemplos utilizan Nuxt Content, los componentes se pueden integrar con cualquier sistema de gestión de contenido.
Dentro de una página
Utilice el componente PageLinks en la ranura bottom del componente ContentToc para mostrar una lista de enlaces debajo de la tabla de contenido.
pages/[...slug].vue
<script setup lang="ts">
import type { PageLink } from '@nuxt/ui'
const route = useRoute()
definePageMeta({
layout: 'docs'
})
const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('docs').path(route.path).first()
})
const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
return queryCollectionItemSurroundings('content', route.path)
})
const links = computed<PageLink[]>(() => [{
icon: 'i-lucide-file-pen',
label: 'Edit this page',
to: `https://github.com/nuxt/ui/edit/v4/docs/content/${page?.value?.stem}.md`,
target: '_blank'
}, {
icon: 'i-lucide-star',
label: 'Star on GitHub',
to: 'https://github.com/nuxt/ui',
target: '_blank'
}, {
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/nuxt/ui/releases'
}])
</script>
<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />
<UPageBody>
<ContentRenderer :value="page" />
<USeparator />
<UContentSurround :surround="surround" />
</UPageBody>
<template #right>
<UContentToc :links="page.body.toc.links">
<template #bottom>
<USeparator type="dashed" />
<UPageLinks title="Community" :links="links" />
</template>
</UContentToc>
</template>
</UPage>
</template>
API
Props (accesorios)
| Prop | Default | Type |
|---|---|---|
as | 'nav' | anyThe element or component this component should render as. |
title | string | |
links | T[] | |
ui | { root?: SlotClass; title?: SlotClass; list?: SlotClass; item?: SlotClass; link?: SlotClass; linkLeadingIcon?: SlotClass; linkLabel?: SlotClass; linkLabelExternalIcon?: SlotClass; } |
Slots
| Slot | Type |
|---|---|
title | {} |
link | { link: T; active: boolean; ui: object; } |
link-leading | { link: T; active: boolean; ui: object; } |
link-label | { link: T; active: boolean; } |
link-trailing | { link: T; active: boolean; } |
Temas
app.config.ts
export default defineAppConfig({
ui: {
pageLinks: {
slots: {
root: 'flex flex-col gap-3',
title: 'text-sm font-semibold flex items-center gap-1.5',
list: 'flex flex-col gap-2',
item: 'relative',
link: 'group text-sm flex items-center gap-1.5 rounded-sm outline-primary/25 focus-visible:outline-3',
linkLeadingIcon: 'size-5 shrink-0',
linkLabel: 'truncate',
linkLabelExternalIcon: 'size-3 absolute top-0 text-dimmed'
},
variants: {
active: {
true: {
link: 'text-primary font-medium'
},
false: {
link: [
'text-muted hover:text-default',
'transition-colors'
]
}
}
}
}
}
})vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pageLinks: {
slots: {
root: 'flex flex-col gap-3',
title: 'text-sm font-semibold flex items-center gap-1.5',
list: 'flex flex-col gap-2',
item: 'relative',
link: 'group text-sm flex items-center gap-1.5 rounded-sm outline-primary/25 focus-visible:outline-3',
linkLeadingIcon: 'size-5 shrink-0',
linkLabel: 'truncate',
linkLabelExternalIcon: 'size-3 absolute top-0 text-dimmed'
},
variants: {
active: {
true: {
link: 'text-primary font-medium'
},
false: {
link: [
'text-muted hover:text-default',
'transition-colors'
]
}
}
}
}
}
})
]
})Changelog (Edición española)
No recent changes