Implement breadcrum navigation

This commit is contained in:
mido
2026-04-15 11:34:53 -05:00
parent 549f131ffd
commit a8186111ac
6 changed files with 68 additions and 7 deletions

View File

@@ -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>