Files
blitzkit/packages/website-ue/src/components/HighlightedCodeBlock.astro
T

23 lines
552 B
Plaintext
Raw Normal View History

2026-03-19 18:17:36 -05:00
---
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} />