mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-17 10:53:57 +01:00
feat: macro names
This commit is contained in:
1 parent
6a58c5ea1d
commit
8d3678ddcb
8 files changed
+64
-29
No files matched your search
@@ -9,7 +9,12 @@ interface Props {
|
||||
}
|
||||
|
||||
const macroPattern = /@(\w+) (.+)/;
|
||||
const macros: Record<string, string> = {};
|
||||
const macros: Record<string, string[]> = {};
|
||||
|
||||
const macroComponents = {
|
||||
see: ApiMacroSee,
|
||||
type: ApiMacroType,
|
||||
};
|
||||
|
||||
const { body: bodyOriginal, locale } = Astro.props;
|
||||
let body = "";
|
||||
@@ -25,7 +30,11 @@ for (const line of bodyOriginal.split("\n")) {
|
||||
const macro = match[1];
|
||||
const value = match[2];
|
||||
|
||||
macros[macro] = value;
|
||||
if (macro in macros) {
|
||||
macros[macro].push(value);
|
||||
} else {
|
||||
macros[macro] = [value];
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
@@ -56,7 +65,17 @@ for (const line of bodyOriginal.split("\n")) {
|
||||
<div class="content">
|
||||
<MarkdownCustom {body} />
|
||||
|
||||
{"see" in macros && <ApiMacroSee {locale} value={macros.see} />}
|
||||
{"type" in macros && <ApiMacroType {locale} value={macros.type} />}
|
||||
<!-- {"see" in macros && <ApiMacroSee {locale} value={macros.see} />}
|
||||
{"type" in macros && <ApiMacroType {locale} value={macros.type} />} -->
|
||||
|
||||
{
|
||||
Object.entries(macroComponents).map(([macro, Component]) => {
|
||||
if (!(macro in macros)) return null;
|
||||
|
||||
return macros[macro].map((value) => {
|
||||
return <Component {locale} value={value} />;
|
||||
});
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user