import { EuiLink , EuiLinkAnchorProps } from '@elastic/eui' ; import React from 'react' ; import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context' ; type DocsSection = '/apm/get-started' | '/x-pack' | '/apm/server' | '/kibana' | '/elasticsearch/reference' | '/cloud' ; interface Props extends EuiLinkAnchorProps { section : DocsSection ; path : string ; } export function ElasticDocsLink ( { section , path , children , ... rest } ) { const { docLinks } = useApmPluginContext ( ) . core ; const baseUrl = docLinks . ELASTIC_WEBSITE_URL ; const version = section === '/cloud' ? 'current' : docLinks . DOC_LINK_VERSION ; const href = `${ baseUrl }guide/en${ section }/${ version }${ path }` ; return typeof children === 'function' ? ( children ( href ) ) : ( < EuiLink href = { href } { ... rest } > { children } < /EuiLink>); }