mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-07 16:06:12 +02:00
feat(resources): capitalize breadcrumbs + add home
Fixed linting errors Fix linting errors again
This commit is contained in:
committed by
Jean-Philippe Sirois
parent
adb2a925ba
commit
e53ed690df
@@ -9,8 +9,17 @@ interface IResourceBreadcrumbProps {
|
|||||||
relativePath: any
|
relativePath: any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function capitalize(str: string): string {
|
||||||
|
const split = str.split(" ")
|
||||||
|
const reconstruct = []
|
||||||
|
for (const substr of split) {
|
||||||
|
reconstruct.push(`${substr.charAt(0).toUpperCase()}${substr.substring(1)}`)
|
||||||
|
}
|
||||||
|
return reconstruct.join(" ")
|
||||||
|
}
|
||||||
|
|
||||||
function Link({ item }: { item: IFileOrFolder }) {
|
function Link({ item }: { item: IFileOrFolder }) {
|
||||||
return <SC.StyledLink to={item.path}>{item.title}</SC.StyledLink>
|
return <SC.StyledLink to={item.path}>{capitalize(item.title)}</SC.StyledLink>
|
||||||
}
|
}
|
||||||
|
|
||||||
function flatten([
|
function flatten([
|
||||||
@@ -30,6 +39,23 @@ export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SC.ResourceBreadcrumbWrapper>
|
<SC.ResourceBreadcrumbWrapper>
|
||||||
|
<SC.LinkWrapper>
|
||||||
|
<Link
|
||||||
|
item={{ path: "/", title: "Home", type: "folder", children: [] }}
|
||||||
|
/>
|
||||||
|
<ChevronUp />
|
||||||
|
</SC.LinkWrapper>
|
||||||
|
<SC.LinkWrapper>
|
||||||
|
<Link
|
||||||
|
item={{
|
||||||
|
path: "/resources",
|
||||||
|
title: "Resources",
|
||||||
|
type: "folder",
|
||||||
|
children: [],
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ChevronUp />
|
||||||
|
</SC.LinkWrapper>
|
||||||
{breadcrumbItems.map(item => {
|
{breadcrumbItems.map(item => {
|
||||||
if (item.type === "folder") {
|
if (item.type === "folder") {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user