Only link the first folder when rendering breadcrumbs

This commit is contained in:
puremana
2020-02-12 21:37:00 +13:00
parent a4e04e376c
commit 98521d8062
+15 -4
View File
@@ -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 (