import React from 'react'; import ReactMarkdown from 'react-markdown'; import autolinkHeadings from 'rehype-autolink-headings'; import gfm from 'remark-gfm'; import slug from 'rehype-slug'; import { DocumentData } from '@nrwl/nx-dev/data-access-documents'; import { sendCustomEvent } from '@nrwl/nx-dev/feature-analytics'; import { transformLinkPath } from './renderers/transform-link-path'; import { transformImagePath } from './renderers/transform-image-path'; import { renderIframes } from './renderers/render-iframe'; import { CodeBlock } from './code-block'; export interface ContentProps { document: DocumentData; flavor: string; version: string; } interface ComponentsConfig { readonly code: { callback: (command: string) => void }; } const components: any = (config: ComponentsConfig) => ({ code({ node, inline, className, children, ...props }) { const language = /language-(\w+)/.exec(className || '')?.[1]; return !inline && language ? ( config.code.callback(command)} /> ) : ( {children} ); }, pre({ children }) { return <>{children}; }, }); export function Content(props: ContentProps) { return (
sendCustomEvent( 'code-snippets', 'click', props.document.filePath ), }, })} />
); } export default Content;