Skip to content

Commit ded6120

Browse files
committed
fix
1 parent 9312816 commit ded6120

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/components/CodeTabs.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,21 @@ export default function CodeTabs() {
9898

9999
useEffect(() => {
100100
const { code, lang } = FILES[active];
101-
codeToHtml(code, { lang, theme: "min-dark" }).then((html) => {
101+
// @ts-ignore
102+
import("https://unpkg.com/shiki@1.22.0/dist/index.mjs")
103+
.then(async (shiki) => {
104+
// pastikan pakai CDN untuk themes
105+
if (shiki.setCDN) shiki.setCDN("https://unpkg.com/shiki/");
106+
const html = await shiki.codeToHtml(code, {
107+
lang,
108+
theme: "github-dark", // atau 'dracula', bebas
109+
});
102110
const clean = html.replace(/background-color:[^;"]+;?/g, "");
103111
setHighlighted(clean);
112+
})
113+
.catch((err) => {
114+
console.error("Shiki load error:", err);
115+
setHighlighted(`<pre>${code}</pre>`);
104116
});
105117
}, [active]);
106118

0 commit comments

Comments
 (0)