Merge pull request #226 from puremana/fixing-breadcrumbs-404

Fixing breadcrumbs 404 & Unique key prop warning on resource sidebar
This commit is contained in:
Jean-Philippe Sirois
2020-02-16 15:13:14 -05:00
committed by GitHub
2 changed files with 17 additions and 6 deletions
+15 -4
View File
@@ -32,7 +32,7 @@ function flatten([
export function Breadcrumb({ relativePath, basePath }: IBreadcrumbProps) {
const paths = relativePath.split("/")
const breadcrumbItems = flatten([traversePaths(paths, basePath)])
let foldersDepth = 0;
return (
<SC.BreadcrumbWrapper>
<SC.LinkWrapper>
@@ -52,14 +52,25 @@ export function Breadcrumb({ relativePath, basePath }: IBreadcrumbProps) {
/>
<ChevronUp />
</SC.LinkWrapper>
{breadcrumbItems.map(item => {
if (item.type === "folder") {
return (
foldersDepth++;
if (foldersDepth > 1) {
return (
<SC.LinkWrapper key={item.path}>
<Link item={item} />
{ item.title }
<ChevronUp />
</SC.LinkWrapper>
)
)
} else {
return (
<SC.LinkWrapper key={item.path}>
<Link item={item} />
<ChevronUp />
</SC.LinkWrapper>
)
}
}
return (
+2 -2
View File
@@ -99,7 +99,7 @@ function Folder({ item }: { item: IFolder }) {
</SC.Label>
<SC.Children>
{sortedChildren.map(node => (
<Tree item={node} />
<Tree key={node.title + '-tree'} item={node} />
))}
</SC.Children>
</SC.TreeWrapper>
@@ -120,7 +120,7 @@ const FirstLevelFolder = memo(({ item }: { item: IFolder }) => {
<SC.FirstLabel>{humanize(item.title)}</SC.FirstLabel>
<SC.Children>
{sortedChildren.map(node => (
<Tree item={node} />
<Tree key={node.title + '-tree'} item={node} />
))}
</SC.Children>
</SC.TreeWrapper>