-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<Breadcrumbs :breadcrumb-items="breadcrumbItems" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { NavItem } from '@nuxt/content' | ||
import type { BreadcrumbItem } from './BreadcrumbsTypes' | ||
// import type { BreadcrumbItem } from '~/components/BreadcrumbsTypes' | ||
const { data: navigation } = await useAsyncData('navigation', () => | ||
fetchContentNavigation() | ||
) | ||
const route = useRoute() | ||
function shallowNavitems(navItems: NavItem[] | null | undefined): NavItem[] { | ||
if (!navItems) return [] | ||
return [ | ||
...navItems, | ||
...navItems.map((navItem) => shallowNavitems(navItem.children)) | ||
].flat(10) | ||
} | ||
function navItemToBreadcrumbItem(navItem: NavItem): BreadcrumbItem { | ||
return { | ||
url: navItem._path, | ||
label: navItem.title | ||
} | ||
} | ||
const breadcrumbItems = shallowNavitems(navigation.value) | ||
.filter((item) => route.path.substring(0, item._path.length) === item._path) | ||
.sort((a, b) => { | ||
return a._path.length - b._path.length | ||
}) | ||
.map(navItemToBreadcrumbItem) | ||
// function navigationToBreadcrumbs(navigation: Navigation): BreadcrumbItem[] { | ||
// return navigation.map( | ||
// (item): BreadcrumbItem => ({ | ||
// url: item._path, | ||
// label: item.title | ||
// }) | ||
// ) | ||
// } | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
--- | ||
title: About | ||
--- | ||
|
||
# Hello Content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
--- | ||
title: Subpub Statistics | ||
--- | ||
|
||
# Subpub Stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Test Is Not In Path | ||
--- | ||
|
||
# my title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
<template> | ||
<div class="min-h-[100vh]"> | ||
<div class="container mx-auto"> | ||
<Breadcrumbs :breadcrumb-items="breadcrumbItems" /> | ||
<ContentBreadcrumbs /> | ||
<ContentDoc /> | ||
<ContentDocLastUpdated /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { startCase } from 'lodash-es' | ||
import _contentMetadata from '../content-metadata.json' | ||
import type { BreadcrumbItem } from '~/components/BreadcrumbsTypes' | ||
const route = useRoute() | ||
const { data: page } = await useAsyncData('my-page', queryContent('/').findOne) | ||
const pathParts = route.path.substring(1).split('/') | ||
// const { data: navigation } = await useAsyncData('navigation', () => | ||
// fetchContentNavigation() | ||
// ) | ||
const breadcrumbItems: BreadcrumbItem[] = [ | ||
{ url: '/', label: 'Home' }, | ||
...pathParts.map((pathPart, index, arr) => ({ | ||
url: `/${arr.slice(0, index + 1).join('/')}`, | ||
label: startCase(pathPart) | ||
})) | ||
] | ||
useContentHead(page) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters