feat(shared): Added DocsLink component
This commit is contained in:
parent
ce43e9d528
commit
4f867a71e9
2 changed files with 9 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import get from 'lodash.get'
|
||||
import { useNavigation } from 'site/hooks/use-navigation.mjs'
|
||||
import Link from 'next/link'
|
||||
|
||||
const getPage = {
|
||||
dev: (slug, nav) => get(nav, slug.split('/')),
|
||||
|
@ -17,3 +18,9 @@ export const DocsTitle = ({ slug, className = '', site = 'org' }) => {
|
|||
|
||||
return page ? <span className={className}>{page.t}</span> : null
|
||||
}
|
||||
|
||||
export const DocsLink = (props) => (
|
||||
<Link href={`${props.site === 'org' ? '/docs/' : ''}${props.slug}`}>
|
||||
<DocsTitle {...props} />
|
||||
</Link>
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ import { TabbedExample as Example } from './tabbed-example.mjs'
|
|||
import { HttpMethod, HttpStatusCode } from './http.mjs'
|
||||
import { ControlTip } from '../control/tip.mjs'
|
||||
import { Legend } from './legend.mjs'
|
||||
import { DocsTitle } from './docs-title.mjs'
|
||||
import { DocsTitle, DocsLink } from './docs-title.mjs'
|
||||
import { V3Wip } from '../v3-wip.mjs'
|
||||
|
||||
export const components = (site = 'org') => {
|
||||
|
@ -36,6 +36,7 @@ export const components = (site = 'org') => {
|
|||
ControlTip,
|
||||
Example,
|
||||
DocsTitle: (props) => <DocsTitle {...props} site={site} />,
|
||||
DocsLink: (props) => <DocsLink {...props} site={site} />,
|
||||
}
|
||||
|
||||
return site === 'dev'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue