Files
blitzkit/packages/website-ue/src/components/HighlightedCodeBlock.astro
T
2026-03-19 18:26:08 -05:00

24 lines
552 B
Plaintext

---
import { all, createStarryNight } from "@wooorm/starry-night";
import { HighlightedCodeContent } from "./HighlightedCodeContent";
interface Props {
lang: string;
content: string;
}
const { lang, content } = Astro.props;
const starryNight = await createStarryNight(all);
const scope = starryNight.flagToScope(lang);
if (scope === undefined && lang.length > 0) {
throw new Error(`Unsupported language: ${lang}`);
}
const tree =
lang.length === 0 ? content : starryNight.highlight(content, scope!);
---
<HighlightedCodeContent {tree} />