diff --git a/src/components/ResourceBreadcrumb/index.tsx b/src/components/ResourceBreadcrumb/index.tsx index 83dbc35..5637a8f 100644 --- a/src/components/ResourceBreadcrumb/index.tsx +++ b/src/components/ResourceBreadcrumb/index.tsx @@ -1,3 +1,4 @@ +import pipe from "ramda/es/pipe" import React from "react" import ChevronUp from "../../icons/chevron-up.svg" @@ -9,8 +10,26 @@ interface IResourceBreadcrumbProps { relativePath: any } +function capitalize(str: string): string { + return str + .split(" ") + .map(word => `${word.charAt(0).toUpperCase()}${word.substring(1)}`) + .join(" ") +} + +function dashToSpace(str: string): string { + return str.replace("-", " ") +} + +function humanize(str: string): string { + return pipe( + dashToSpace, + capitalize + )(str) +} + function Link({ item }: { item: IFileOrFolder }) { - return {item.title} + return {humanize(item.title)} } function flatten([ @@ -30,6 +49,23 @@ export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) { return ( + + + + + + + + {breadcrumbItems.map(item => { if (item.type === "folder") { return (