Skip to content
Snippets Groups Projects
ApiLink.js 372 B
import React from "react"
import Link from '@docusaurus/Link'

export default ({api, to, withMethod = 'get', children}) => {
  const url = `/docs/apis/${api}#${withMethod.toLowerCase()}-${to.replace(/[{}]/g, '-')}`
  if (children) {
    return <Link to={url}>{children}</Link>
  } else {
    return <Link to={url}><code>{withMethod.toUpperCase()} {to}</code></Link>
  }
}