mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
Merge pull request #226 from puremana/fixing-breadcrumbs-404
Fixing breadcrumbs 404 & Unique key prop warning on resource sidebar
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user