--- import ApiMacroSee from "./ApiMacroSee.astro"; import ApiMacroType from "./ApiMacroType.astro"; import { MarkdownCustom } from "./MarkdownCustom"; interface Props { body: string; locale: string; } const macroPattern = /@(\w+) (.+)/; const macros: Record = {}; const macroComponents = { see: ApiMacroSee, type: ApiMacroType, }; const { body: bodyOriginal, locale } = Astro.props; let body = ""; for (const line of bodyOriginal.split("\n")) { const match = line.match(macroPattern); if (match === null) { body += `${line}\n`; continue; } const macro = match[1]; const value = match[2]; if (macro in macros) { macros[macro].push(value); } else { macros[macro] = [value]; } } ---
{ Object.entries(macroComponents).map(([macro, Component]) => { if (!(macro in macros)) return null; return macros[macro].map((value) => { return ; }); }) }