diff --git a/.changeset/tasty-timers-travel.md b/.changeset/tasty-timers-travel.md
new file mode 100644
index 00000000..d804635c
--- /dev/null
+++ b/.changeset/tasty-timers-travel.md
@@ -0,0 +1,5 @@
+---
+'web': minor
+---
+
+Refactored breadcrumb component to comply with new navigation structure
diff --git a/apps/web/src/app/(common-page)/agenda/[event]/page.tsx b/apps/web/src/app/(common-page)/agenda/[event]/page.tsx
index 49438be4..0b2ccbf9 100644
--- a/apps/web/src/app/(common-page)/agenda/[event]/page.tsx
+++ b/apps/web/src/app/(common-page)/agenda/[event]/page.tsx
@@ -16,6 +16,7 @@ import { OpenInMapDropdown } from './open-in-map-dropdown';
import { Metadata } from 'next';
import { truncateStringAtWord } from '@/common/truncate-string-at-word';
import slugify from '@sindresorhus/slugify';
+import { EnhanceMenuBreadcrumbs } from '@/app/menu-breadcrumbs';
interface Props {
params: { event: string };
@@ -35,6 +36,8 @@ export default async function EventPage({ params }: Props) {
return (
<>
+
+
{cover && (
+
+
-
-
-
-
- } href="/blog">
- Overzicht
-
-
- {blogArticle.title}
-
- {blogArticle.publishedAt && (
-
- Publicatiedatum{' '}
- {new Date(blogArticle.publishedAt).toLocaleDateString('nl-NL', {
- month: 'long',
- day: 'numeric',
- year: 'numeric',
- hour: 'numeric',
- minute: 'numeric',
- })}
-
+ } href="/blog">
+ Overzicht
+
+
+ {blogArticle.title}
+
+ {blogArticle.publishedAt && (
+
+ Publicatiedatum{' '}
+ {new Date(blogArticle.publishedAt).toLocaleDateString('nl-NL', {
+ month: 'long',
+ day: 'numeric',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric',
+ })}
+
+ )}
+
-
-
-
- Categorie: {blogArticle?.category}
+
+
+
+
+
+ Categorie: {blogArticle?.category}
- Deel deze pagina
-
-
- >
+ Deel deze pagina
+
+
);
}
diff --git a/apps/web/src/app/(common-page)/breadcrumbs.tsx b/apps/web/src/app/(common-page)/breadcrumbs.tsx
deleted file mode 100644
index 84a9512d..00000000
--- a/apps/web/src/app/(common-page)/breadcrumbs.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-'use client';
-
-import { Breadcrumbs as BreadcrumbsComponent } from '@/components/breadcrumbs';
-import { getPages } from '@/services/cms/get-pages';
-import Link from 'next/link';
-import { usePathname } from 'next/navigation';
-
-interface Props {
- pages: Awaited>;
-}
-
-export const Breadcrumbs: React.FC = ({ pages }) => {
- const pathName = usePathname();
-
- const page = pages.find((page) => page.slug && pathName.includes(page.slug));
-
- return (
-
-
-
- );
-};
diff --git a/apps/web/src/app/(common-page)/layout.tsx b/apps/web/src/app/(common-page)/layout.tsx
deleted file mode 100644
index 8b52c336..00000000
--- a/apps/web/src/app/(common-page)/layout.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { getPages } from '@/services/cms/get-pages';
-import { Breadcrumbs } from './breadcrumbs';
-
-export const revalidate = 300;
-
-export default async function CommonPageLayout({ children }: React.PropsWithChildren) {
- const pages = await getPages();
-
- return (
- <>
-
- {children}
- >
- );
-}
diff --git a/apps/web/src/app/header.tsx b/apps/web/src/app/header.tsx
index f4f3cb26..9580a765 100644
--- a/apps/web/src/app/header.tsx
+++ b/apps/web/src/app/header.tsx
@@ -6,6 +6,7 @@ import Logo from './logo.png';
import { MenuContext } from './menu-context';
import { MenuDesktop } from './menu-desktop';
import { MenuMobile, MenuToggle } from './menu-mobile';
+import { MenuBreadcrumbs } from './menu-breadcrumbs';
export interface Page {
id: number;
@@ -28,6 +29,7 @@ export const Header: React.FC = async () => {
+
);
};
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
index 71c0c4be..717e64bf 100644
--- a/apps/web/src/app/layout.tsx
+++ b/apps/web/src/app/layout.tsx
@@ -3,6 +3,7 @@ import localFont from 'next/font/local';
import { Footer } from './footer';
import './globals.css';
import { Header } from './header';
+import { MenuBreadcrumbsProvider } from './menu-breadcrumbs';
const RoSansWeb = localFont({
src: [
@@ -22,9 +23,11 @@ export default async function RootLayout({ children }: { children: React.ReactNo
return (
-
- {children}
-
+
+
+ {children}
+
+
);
diff --git a/apps/web/src/app/menu-breadcrumbs.tsx b/apps/web/src/app/menu-breadcrumbs.tsx
new file mode 100644
index 00000000..a412a239
--- /dev/null
+++ b/apps/web/src/app/menu-breadcrumbs.tsx
@@ -0,0 +1,117 @@
+'use client';
+
+import { Container } from '@/components/container';
+import { getNavbarNodeByUrl } from '@/services/cms/get-navbar-node-by-url';
+import { NavbarNode } from '@/services/cms/get-navbar-tree';
+import { IconChevronRight } from '@tabler/icons-react';
+import Link from 'next/link';
+import { usePathname } from 'next/navigation';
+import React, {
+ Dispatch,
+ Fragment,
+ PropsWithChildren,
+ SetStateAction,
+ createContext,
+ useContext,
+ useEffect,
+ useState,
+} from 'react';
+
+interface CrumbProps {
+ name: string;
+ href?: string;
+}
+
+const Crumb: React.FC = ({ name, href }) => {
+ if (name === 'root') return Home;
+
+ if (!href) return {name};
+
+ return {name};
+};
+
+interface MenuBreadcrumbsProps {
+ navbar: NavbarNode;
+}
+
+export const MenuBreadcrumbs: React.FC = ({ navbar }) => {
+ const { additionalCrumbs } = useMenuBreadcrumbs();
+ const pathName = usePathname();
+
+ const pathSegments = pathName.split('/');
+
+ const targetNode = pathSegments[1] || '/';
+
+ const node = getNavbarNodeByUrl(navbar, targetNode);
+
+ if (!node) return null;
+
+ const nodes = [node];
+ let current = node;
+
+ while (current.parent) {
+ current = current.parent;
+ nodes.push(current);
+ }
+
+ return (
+
+
+ {nodes.toReversed().map((node, i) => {
+ return (
+
+ {i > 0 && }
+
+
+ );
+ })}
+ {additionalCrumbs.map((name, i) => {
+ return (
+
+
+
+
+ );
+ })}
+
+
+ );
+};
+
+interface Value {
+ additionalCrumbs: string[];
+ setAdditionalCrumbs: Dispatch>;
+}
+
+const context = createContext({} as Value);
+
+interface MenuBreadcrumbsProvider extends PropsWithChildren {}
+
+export const MenuBreadcrumbsProvider: React.FC = ({ children }) => {
+ const [additionalCrumbs, setAdditionalCrumbs] = useState([]);
+
+ console.log({ additionalCrumbs });
+
+ return {children};
+};
+
+const useMenuBreadcrumbs = () => useContext(context);
+
+interface EnhanceMenuBreadcrumbsProps {
+ append: string;
+}
+
+export const EnhanceMenuBreadcrumbs: React.FC = ({ append }) => {
+ const { setAdditionalCrumbs } = useMenuBreadcrumbs();
+
+ useEffect(() => {
+ setAdditionalCrumbs([append]);
+
+ return () => {
+ console.log('cleanup');
+ setAdditionalCrumbs([]);
+ };
+ }, [append, setAdditionalCrumbs]);
+
+ return null;
+};
diff --git a/apps/web/src/components/breadcrumbs.tsx b/apps/web/src/components/breadcrumbs.tsx
deleted file mode 100644
index 1753a062..00000000
--- a/apps/web/src/components/breadcrumbs.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { joinChildren } from '@/common/join-children';
-import { IconChevronRight } from '@tabler/icons-react';
-import { Container } from './container';
-
-export const Breadcrumbs: React.FC = ({ children }) => {
- return (
-
-
- {Array.isArray(children) ? joinChildren(children, ) : children}
-
-
- );
-};