1
1
mirror of https://github.com/primer/css.git synced 2024-12-01 04:21:12 +03:00
css/docs/src/NodeLink.js

14 lines
385 B
JavaScript
Raw Normal View History

2018-12-05 08:46:36 +03:00
import React from 'react'
import Link from './Link'
import {rootPage} from './utils'
export default function NodeLink(props) {
const {href, children: content} = props
if (content) {
return <Link {...props} />
}
const node = rootPage.first(node => node.path === href)
const children = (node ? node.meta.title : null) || href
return <Link {...props}>{children}</Link>
}