Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit a6915ba

Browse files
committed
Display breadcrumbs in layout
1 parent ef17120 commit a6915ba

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

components/common/Layout.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default function Layout({children, seo, hasJsonLd}) {
2828
}
2929
]
3030

31+
// Extract breadcrumbs from SEO.
32+
const breadcrumbs = seo?.breadcrumbs
33+
3134
return (
3235
<>
3336
<NextSeo
@@ -55,7 +58,23 @@ export default function Layout({children, seo, hasJsonLd}) {
5558
)}
5659
<Meta />
5760
<Header />
58-
<main>{children}</main>
61+
<main>
62+
{/* TODO: extract breadcrumbs to component and make pretty. */}
63+
{!!breadcrumbs && !!breadcrumbs.length && (
64+
<div>
65+
{breadcrumbs.map((breadcrumb, index) => (
66+
<>
67+
<span key={index}>
68+
<a href={breadcrumb?.url}>{breadcrumb?.text}</a>
69+
</span>
70+
{index < breadcrumbs.length - 1 && <span> &raquo; </span>}
71+
</>
72+
))}
73+
</div>
74+
)}
75+
76+
{children}
77+
</main>
5978
<Footer social={seo?.social} siteTitle={seo?.siteTitle} />
6079
</>
6180
)

0 commit comments

Comments
 (0)