diff --git a/components/breadcrumbs.tsx b/components/breadcrumbs.tsx new file mode 100644 index 0000000..11ace5e --- /dev/null +++ b/components/breadcrumbs.tsx @@ -0,0 +1,32 @@ +import { useContext } from 'react' +import Link from 'next/link' +import UserContext from './user/context' + +export default function Breadcrumbs({ label }: { label: string }) { + const { username, role } = useContext(UserContext) + + if (!label) { + return null + } + + return ( +
+ {role === 'admin' && ( +
+ {username} +
+ )} + <> +

+ + Home + +

+ {'>'} +

+ {label} +

+ +
+ ) +} diff --git a/components/header.tsx b/components/header.tsx index 7810f3e..0c0aa16 100644 --- a/components/header.tsx +++ b/components/header.tsx @@ -1,15 +1,13 @@ -import React, { useContext } from 'react' import Head from 'next/head' import Link from 'next/link' -import UserContext from './user/context' import Logo from './logo' +import Breadcrumbs from './breadcrumbs' export default function Header({ label }: { label?: string }) { - const { username, role } = useContext(UserContext) return ( <> - Pfadi-Bussle {label} + Pfadi-Bussle @@ -22,26 +20,7 @@ export default function Header({ label }: { label?: string }) { - {label && ( -
- {username === 'admin' && ( -
- Admin -
- )} - <> -

- - Home - -

- {'>'} -

- {label} -

- -
- )} + )