2026-03-19 13:26:34 -05:00
|
|
|
---
|
|
|
|
|
import ApiMacroSee from "./ApiMacroSee.astro";
|
2026-03-19 18:17:36 -05:00
|
|
|
import ApiMacroType from "./ApiMacroType.astro";
|
2026-03-19 13:26:34 -05:00
|
|
|
import { MarkdownCustom } from "./MarkdownCustom";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
body: string;
|
2026-03-19 17:17:23 -05:00
|
|
|
locale: string;
|
2026-03-19 13:26:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const macroPattern = /@(\w+) (.+)/;
|
2026-03-19 18:44:00 -05:00
|
|
|
const macros: Record<string, string[]> = {};
|
|
|
|
|
|
|
|
|
|
const macroComponents = {
|
|
|
|
|
see: ApiMacroSee,
|
|
|
|
|
type: ApiMacroType,
|
|
|
|
|
};
|
2026-03-19 13:26:34 -05:00
|
|
|
|
2026-03-19 17:17:23 -05:00
|
|
|
const { body: bodyOriginal, locale } = Astro.props;
|
2026-03-19 13:26:34 -05:00
|
|
|
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];
|
|
|
|
|
|
2026-03-19 18:44:00 -05:00
|
|
|
if (macro in macros) {
|
|
|
|
|
macros[macro].push(value);
|
|
|
|
|
} else {
|
|
|
|
|
macros[macro] = [value];
|
|
|
|
|
}
|
2026-03-19 13:26:34 -05:00
|
|
|
}
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.api-description {
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
|
|
.gutter {
|
|
|
|
|
width: var(--space-2);
|
2026-03-20 14:52:06 -05:00
|
|
|
background: linear-gradient(
|
|
|
|
|
transparent,
|
|
|
|
|
var(--gray-6) var(--space-4),
|
|
|
|
|
var(--gray-6) calc(100% - var(--space-4)),
|
|
|
|
|
transparent
|
|
|
|
|
);
|
2026-03-19 13:26:34 -05:00
|
|
|
|
|
|
|
|
margin: 0 var(--space-4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.content {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: var(--space-4);
|
|
|
|
|
|
|
|
|
|
padding-top: var(--space-4);
|
|
|
|
|
padding-bottom: var(--space-3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<div class="api-description">
|
|
|
|
|
<div class="gutter"></div>
|
|
|
|
|
<div class="content">
|
|
|
|
|
<MarkdownCustom {body} />
|
2026-03-19 18:17:36 -05:00
|
|
|
|
2026-03-19 18:44:00 -05:00
|
|
|
{
|
|
|
|
|
Object.entries(macroComponents).map(([macro, Component]) => {
|
|
|
|
|
if (!(macro in macros)) return null;
|
|
|
|
|
|
|
|
|
|
return macros[macro].map((value) => {
|
|
|
|
|
return <Component {locale} value={value} />;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-03-19 13:26:34 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|