Use the surround prop with the surround value you get when fetching a page surround.
<script setup lang="ts">
import { useAsyncData, useRoute } from '#app';
import { queryCollectionItemSurroundings } from '#imports';
const route = useRoute();
const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
return queryCollectionItemSurroundings('docs', route.path, {
fields: ['description'],
});
});
</script>
<template>
<PContentSurround :surround="(surround as any)" />
</template>
Use the prev-icon and next-icon props to customize the buttons Icon.
<script setup lang="ts">
const surround = ref([
{
title: 'ContentSearchButton',
path: '/docs/pohon/components/content-search-button',
stem: '3.components/content-search-button',
description: 'A pre-styled Button to open the ContentSearch modal.'
},
{
title: 'ContentToc',
path: '/docs/pohon/components/content-toc',
stem: '3.components/content-toc',
description: 'A sticky Table of Contents with customizable slots.'
}
])
</script>
<template>
<PContentSurround
prev-icon="i-lucide:chevron-left"
next-icon="i-lucide:chevron-right"
:surround="surround"
/>
</template>
Use the ContentSurround component in a page to display the prev and next links:
<script setup lang="ts">
const route = useRoute();
const { data: page } = await useAsyncData(route.path, () => queryCollection('docs').path(route.path).first());
if (!page.value) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true });
}
</script>
<template>
<ExamplePage v-if="page">
<ExamplePageHeader :title="page.title" />
<ExamplePageBody>
<ContentRenderer
v-if="page.body"
:value="page"
/>
<PSeparator v-if="surround?.filter(Boolean).length" />
<PContentSurround :surround="(surround as any)" />
</ExamplePageBody>
<template
v-if="page?.body?.toc?.links?.length"
#right
>
<PContentToc :links="page.body.toc.links" />
</template>
</ExamplePage>
</template>
| Prop | Default | Type |
|---|
| Slot | Type |
|---|
Below is the theme configuration skeleton for the PContentSurround. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.
export default defineAppConfig({
pohon: {
contentSurround: {
slots: {
root: '',
link: '',
linkLeading: '',
linkLeadingIcon: '',
linkTitle: '',
linkDescription: ''
},
variants: {
direction: {
left: {
linkLeadingIcon: ''
},
right: {
link: '',
linkLeadingIcon: ''
}
}
}
}
}
};
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'
export default defineAppConfig({
pohon: {
contentSurround: {
slots: {
root: '',
link: '',
linkLeading: '',
linkLeadingIcon: '',
linkTitle: '',
linkDescription: ''
},
variants: {
direction: {
left: {
linkLeadingIcon: ''
},
right: {
link: '',
linkLeadingIcon: ''
}
}
}
}
}
};