Skip to content

Commit

Permalink
feat: modify header to display breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
itsacoyote committed Apr 1, 2024
1 parent fa9935c commit 3903211
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import type { NavItem } from '@nuxt/content/types';
import { withoutTrailingSlash } from 'ufo';
definePageMeta({
Expand All @@ -8,6 +9,8 @@ definePageMeta({
const route = useRoute();
const { toc, seo } = useAppConfig();
const navigation = inject<Ref<NavItem[]>>('navigation', ref([]));
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne());
if (!page.value) {
Expand All @@ -34,7 +37,9 @@ defineOgImage({
description: page.value.description,
});
const headline = computed(() => findPageHeadline(page.value));
const breadcrumb = computed(() =>
mapContentNavigation(findPageBreadcrumb(navigation!.value, page.value)).map(({ label }) => ({ label }))
);
const links = computed(() =>
[
Expand All @@ -55,8 +60,11 @@ const links = computed(() =>
:title="page.title"
:description="page.description"
:links="page.links"
:headline="headline"
/>
>
<template #headline>
<UBreadcrumb :links="breadcrumb" />
</template>
</UPageHeader>

<UPageBody prose>
<ContentRenderer
Expand Down

0 comments on commit 3903211

Please sign in to comment.