Implement breadcrum navigation
This commit is contained in:
@@ -30,9 +30,24 @@ if (!collection || !isSiteCollection(collection)) {
|
||||
}
|
||||
|
||||
const { entry } = Astro.props;
|
||||
const entries = await getCollection(collection);
|
||||
const collectionIndex = entries.find((item) => item.id === "index");
|
||||
const entryUrl = entry.id === "index" ? `/${collection}` : `/${collection}/${entry.id}`;
|
||||
const breadcrumbs = [
|
||||
{ label: "Radie Help", href: "/" },
|
||||
{
|
||||
label: collectionIndex?.data.title ?? collection,
|
||||
href: entry.id === "index" ? undefined : `/${collection}`,
|
||||
},
|
||||
];
|
||||
|
||||
if (entry.id !== "index") {
|
||||
breadcrumbs.push({ label: entry.data.title, href: entryUrl });
|
||||
}
|
||||
|
||||
const { Content } = await render(entry);
|
||||
---
|
||||
|
||||
<Layout title={entry.data.title}>
|
||||
<Layout title={entry.data.title} breadcrumbs={breadcrumbs}>
|
||||
<Content />
|
||||
</Layout>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user