mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-09 07:56:12 +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) {
|
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 foldersDepth = 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 (
|
foldersDepth++;
|
||||||
|
if (foldersDepth > 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 (
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ function Folder({ item }: { item: IFolder }) {
|
|||||||
</SC.Label>
|
</SC.Label>
|
||||||
<SC.Children>
|
<SC.Children>
|
||||||
{sortedChildren.map(node => (
|
{sortedChildren.map(node => (
|
||||||
<Tree item={node} />
|
<Tree key={node.title + '-tree'} item={node} />
|
||||||
))}
|
))}
|
||||||
</SC.Children>
|
</SC.Children>
|
||||||
</SC.TreeWrapper>
|
</SC.TreeWrapper>
|
||||||
@@ -120,7 +120,7 @@ const FirstLevelFolder = memo(({ item }: { item: IFolder }) => {
|
|||||||
<SC.FirstLabel>{humanize(item.title)}</SC.FirstLabel>
|
<SC.FirstLabel>{humanize(item.title)}</SC.FirstLabel>
|
||||||
<SC.Children>
|
<SC.Children>
|
||||||
{sortedChildren.map(node => (
|
{sortedChildren.map(node => (
|
||||||
<Tree item={node} />
|
<Tree key={node.title + '-tree'} item={node} />
|
||||||
))}
|
))}
|
||||||
</SC.Children>
|
</SC.Children>
|
||||||
</SC.TreeWrapper>
|
</SC.TreeWrapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user