diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2023-09-06 19:53:23 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2023-09-06 19:53:23 -0500 |
| commit | 6e5037aacc594dbc4ba8e6c3f1824844c09263dd (patch) | |
| tree | 63a0e7031ad1db7488a5f576b4086ed7e91750df /templates/Default/index.tsx | |
| parent | 9b438a42fa712ee131912bf7b5c54711af63e2a8 (diff) | |
Make BreadCrumbs domain agnostic
Diffstat (limited to 'templates/Default/index.tsx')
| -rw-r--r-- | templates/Default/index.tsx | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/templates/Default/index.tsx b/templates/Default/index.tsx index 6adab70..ccfde4a 100644 --- a/templates/Default/index.tsx +++ b/templates/Default/index.tsx @@ -1,8 +1,8 @@ -import clsx from "clsx"; -import React, { FC } from "react"; -import { Breadcrumbs, LinkCrumb } from "../../components/Breadcrumbs"; +import React, { FC } from 'react'; +import PathCrumbs from "../../components/PathCrumbs"; import Viewport from "../../components/ViewPort"; import styles from './default.module.scss'; +import clsx from 'clsx'; export type DefaultPageProps = { className?: string; @@ -11,34 +11,6 @@ export type DefaultPageProps = { children?: React.ReactChild; }; -export type RelPathProps = { - path: string; -}; - -const RelPath : FC<RelPathProps> = ({path, ...props}) => { - const _path = path[path.length - 1] === '/' ? path.substr(0, path.length - 1) : path; - - const parts = _path.split('/'); - const rels = ['']; - - for(let i = 1; i < parts.length; i++) { - rels.push([rels[i - 1], parts[i]].join('/')); - } - - rels[0] = '/'; - parts[0] = 'furkistan.com'; - - return ( - <Breadcrumbs> - {rels.map((relHref, i) => ( - <LinkCrumb key={relHref} href={relHref}> - {parts[i]} - </LinkCrumb> - ))} - </Breadcrumbs> - ); -} - const LastUpdatedDate : FC<{ children: React.ReactNode }> = ({children}) => ( <span className={styles.date}><b>Last Updated: </b>{children}</span> ) @@ -47,7 +19,7 @@ const DefaultPage : FC<DefaultPageProps> = ({className, lastUpdated, children, p <Viewport className={clsx(styles.viewportOverrides, className)} > - {path !== undefined ? <RelPath path={path!} /> : undefined} + {path !== undefined ? <PathCrumbs path={path!} /> : undefined} {lastUpdated ? <LastUpdatedDate>{lastUpdated}</LastUpdatedDate> : undefined} {children} </Viewport> |
