PageLinks
A list of links to be displayed in the page.
Usage
Use the PageLinks component to display a list of links.
<script setup lang="ts">
import type { PageLink } from 'pohon-ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/vinicunca/docs/blob/main/content/pohon/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/vinicunca/pohon'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
])
</script>
<template>
<PPageLinks :links="links" />
</template><script setup lang="ts">
import { ref } from 'vue'
import type { PageLink } from 'pohon-ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/vinicunca/docs/blob/main/content/pohon/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/vinicunca/pohon'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
])
</script>
<template>
<PPageLinks :links="links" />
</template>Links
Use the links prop as an array of objects with the following properties:
label: stringicon?: stringclass?: anyui?: { item?: ClassNameValue, link?: ClassNameValue, linkLabel?: ClassNameValue, linkLabelExternalIcon?: ClassNameValue, linkLeadingIcon?: ClassNameValue }
You can pass any property from the Link component such as to, target, etc.
<script setup lang="ts">
import type { PageLink } from 'pohon-ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/vinicunca/docs/blob/main/content/pohon/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/vinicunca/pohon'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
])
</script>
<template>
<PPageLinks :links="links" />
</template><script setup lang="ts">
import { ref } from 'vue'
import type { PageLink } from 'pohon-ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/vinicunca/docs/blob/main/content/pohon/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/vinicunca/pohon'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
])
</script>
<template>
<PPageLinks :links="links" />
</template>Title
Use the title prop to display a title above the links.
<script setup lang="ts">
import type { PageLink } from 'pohon-ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/vinicunca/docs/blob/main/content/pohon/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/vinicunca/pohon'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
])
</script>
<template>
<PPageLinks title="Community" :links="links" />
</template><script setup lang="ts">
import { ref } from 'vue'
import type { PageLink } from 'pohon-ui'
const links = ref<PageLink[]>([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/vinicunca/docs/blob/main/content/pohon/2.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/vinicunca/pohon'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
])
</script>
<template>
<PPageLinks title="Community" :links="links" />
</template>Examples
While these examples use Nuxt Content, the components can be integrated with any content management system.
Within a page
Use the PageLinks component in the bottom slot of the ContentToc component to display a list of links below the table of contents.
pages/[...slug].vue
<script setup lang="ts">
import type { PageLink } from 'pohon-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<Array<PageLink>>(() => [
{
icon: 'i-lucide-file-pen',
label: 'Edit this page',
to: `https://github.com/vinicunca/pohon/edit/main/docs/content/${page?.value?.stem}.md`,
target: '_blank'
},
{
icon: 'i-lucide-star',
label: 'Star on GitHub',
to: 'https://github.com/vinicunca/pohon',
target: '_blank'
},
{
label: 'Releases',
icon: 'i-lucide-rocket',
to: 'https://github.com/vinicunca/pohon/releases'
}
]);
</script>
<template>
<PPage>
<PPageHeader
:title="page.title"
:description="page.description"
/>
<PPageBody>
<ContentRenderer :value="page" />
<PSeparator />
<PContentSurround :surround="surround" />
</PPageBody>
<template #right>
<PContentToc :links="page.body.toc.links">
<template #bottom>
<PSeparator type="dashed" />
<PPageLinks
title="Community"
:links="links"
/>
</template>
</PContentToc>
</template>
</PPage>
</template>
API
Props
| Prop | Default | Type |
|---|
Slots
| Slot | Type |
|---|
Theme
app.config.ts
export default defineAppConfig({
ui: {
pageLinks: {
slots: {
root: 'flex flex-col gap-3',
title: 'text-sm font-600 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 color-text-dimmed'
},
variants: {
active: {
true: {
link: 'color-primary font-500'
},
false: {
link: [
'color-text-muted hover:color-text',
'transition-colors'
]
}
}
}
}
}
})vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from 'pohon-ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pageLinks: {
slots: {
root: 'flex flex-col gap-3',
title: 'text-sm font-600 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 color-text-dimmed'
},
variants: {
active: {
true: {
link: 'color-primary font-500'
},
false: {
link: [
'color-text-muted hover:color-text',
'transition-colors'
]
}
}
}
}
}
})
]
})Changelog
No recent changes