diff --git a/src/components/docs/Breadcrumbs.tsx b/src/components/docs/Breadcrumbs.tsx new file mode 100644 index 0000000000..74c323322f --- /dev/null +++ b/src/components/docs/Breadcrumbs.tsx @@ -0,0 +1,28 @@ +import { Breadcrumb, BreadcrumbItem, BreadcrumbLink } from '@chakra-ui/react'; +import NextLink from 'next/link'; +import { FC } from 'react'; + +interface Props { + router: any; +} + +export const Breadcrumbs: FC = ({ router }) => { + let pathSplit = router.asPath.split('/'); + pathSplit = pathSplit.splice(1, pathSplit.length); + + return ( + + {pathSplit.map((path: string, idx: number) => { + return ( + + + + {path} + + + + ); + })} + + ); +}; diff --git a/src/components/docs/index.ts b/src/components/docs/index.ts new file mode 100644 index 0000000000..381317adf2 --- /dev/null +++ b/src/components/docs/index.ts @@ -0,0 +1 @@ +export * from './Breadcrumbs' \ No newline at end of file diff --git a/src/pages/[...slug].tsx b/src/pages/[...slug].tsx index ee7b7b16b7..13193f973f 100644 --- a/src/pages/[...slug].tsx +++ b/src/pages/[...slug].tsx @@ -2,12 +2,16 @@ import fs from 'fs'; import matter from 'gray-matter'; import yaml from 'js-yaml'; import ReactMarkdown from 'react-markdown'; -import { Heading } from '@chakra-ui/react'; +import { Heading, Stack } from '@chakra-ui/react'; import MDXComponents from '../components/'; import { ParsedUrlQuery } from 'querystring'; import type { GetStaticPaths, GetStaticProps, NextPage } from 'next'; +import { useRouter } from 'next/router'; +import { Breadcrumbs } from '../components/docs' + import { PageMetadata } from '../components/UI'; + const MATTER_OPTIONS = { engines: { yaml: (s: any) => yaml.load(s, { schema: yaml.JSON_SCHEMA }) as object @@ -69,6 +73,8 @@ interface Props { } const DocPage: NextPage = ({ frontmatter, content }) => { + const router = useRouter() + return ( <> = ({ frontmatter, content }) => { />
- {frontmatter.title} + + + + {frontmatter.title} - {content} + {content} +
);