mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-07 16:06:12 +02:00
Only link the first folder when rendering breadcrumbs
This commit is contained in:
@@ -32,7 +32,7 @@ function flatten([
|
|||||||
export function Breadcrumb({ relativePath, basePath }: IBreadcrumbProps) {
|
export function Breadcrumb({ relativePath, basePath }: IBreadcrumbProps) {
|
||||||
const paths = relativePath.split("/")
|
const paths = relativePath.split("/")
|
||||||
const breadcrumbItems = flatten([traversePaths(paths, basePath)])
|
const breadcrumbItems = flatten([traversePaths(paths, basePath)])
|
||||||
|
let count = 0;
|
||||||
return (
|
return (
|
||||||
<SC.BreadcrumbWrapper>
|
<SC.BreadcrumbWrapper>
|
||||||
<SC.LinkWrapper>
|
<SC.LinkWrapper>
|
||||||
@@ -52,14 +52,25 @@ export function Breadcrumb({ relativePath, basePath }: IBreadcrumbProps) {
|
|||||||
/>
|
/>
|
||||||
<ChevronUp />
|
<ChevronUp />
|
||||||
</SC.LinkWrapper>
|
</SC.LinkWrapper>
|
||||||
|
|
||||||
{breadcrumbItems.map(item => {
|
{breadcrumbItems.map(item => {
|
||||||
if (item.type === "folder") {
|
if (item.type === "folder") {
|
||||||
return (
|
count++;
|
||||||
|
if (count > 1) {
|
||||||
|
return (
|
||||||
<SC.LinkWrapper key={item.path}>
|
<SC.LinkWrapper key={item.path}>
|
||||||
<Link item={item} />
|
{ item.title }
|
||||||
<ChevronUp />
|
<ChevronUp />
|
||||||
</SC.LinkWrapper>
|
</SC.LinkWrapper>
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<SC.LinkWrapper key={item.path}>
|
||||||
|
<Link item={item} />
|
||||||
|
<ChevronUp />
|
||||||
|
</SC.LinkWrapper>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user