/* eslint-disable react/jsx-props-no-spreading */ import React from "react"; import CodeBlock from "@theme-original/CodeBlock"; function Imports({ imports }) { return (
API Reference: {imports.map(({ imported, source, docs }, index) => ( {imported}{index < imports.length - 1 ? ' | ' : ''} ))}
); } export default function CodeBlockWrapper({ children, ...props }) { // Initialize imports as an empty array let imports = []; // Check if children is a string if (typeof children === "string") { // Search for an IMPORTS comment in the code const match = /\n/.exec(children); if (match) { imports = JSON.parse(match[1]); children = children.replace(match[0], ""); } } else if (children.imports) { imports = children.imports; } return ( <> {children} {imports.length > 0 && } ); }