Skip to content

Commit 2fdc296

Browse files
committed
fix crash
1 parent 90e8260 commit 2fdc296

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/notion-shiki-code/src/server/prepare.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Lang, Theme } from "shiki";
1+
import { BUNDLED_LANGUAGES, type Lang, type Theme } from "shiki";
22
import {
33
getTextFromRichText,
44
type BlockObjectResponse,
@@ -90,7 +90,14 @@ export async function shikifyNotionBlock(
9090
...blockOptions,
9191
};
9292

93-
const language = options.language ?? (block.code.language as Lang);
93+
let language = options.language ?? (block.code.language as Lang);
94+
if (
95+
!BUNDLED_LANGUAGES.some(
96+
(bundledLanguage) => bundledLanguage.id === language
97+
)
98+
)
99+
(language as string) = "";
100+
94101
const { codeHtml, foregroundColor, backgroundColor } = await shikiTransform(
95102
getTextFromRichText(block.code.rich_text),
96103
{ ...options, language }

0 commit comments

Comments
 (0)