mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
feat: more decoration
This commit is contained in:
1 parent
c99ed0cb53
commit
b9bbf22f2c
6 files changed
+39
-20
No files matched your search
@@ -0,0 +1,23 @@
|
||||
---
|
||||
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} />
|
||||
Reference in new issue
Block a user