1
0
Fork 0

feat(shared): Added DocsTitle MDX component

This commit is contained in:
joostdecock 2023-05-21 10:11:26 +02:00
parent ea8d540305
commit c3dc282717
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,19 @@
import get from 'lodash.get'
import { useNavigation } from 'site/hooks/use-navigation.mjs'
const getPage = {
dev: (slug, nav) => get(nav, slug.split('/')),
org: (root, nav) => {
// Fixme: make this work for org
if (!root) return nav
if (root.indexOf('/') === -1) return nav[root]
return get(nav, root.split('/'))
},
}
export const DocsTitle = ({ slug, className = '', site = 'org' }) => {
const { siteNav } = useNavigation()
const page = getPage[site](slug, siteNav)
return page ? <span className={className}>{page.t}</span> : null
}