mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 13:47:40 +01:00
* update deps * Remove ignoredBuiltDependencies * Fix build errors * try this * update config * add coma * Try this * Revert import change * try this * add wasm import * Load wasm * try this * Revert nitro version change * Revert nitro config change
33 lines
909 B
TypeScript
33 lines
909 B
TypeScript
import { bundledLanguages, type ThemeRegistration } from 'shiki';
|
|
import { createHighlighter } from 'shiki';
|
|
|
|
export type ThemeOptions =
|
|
| ThemeRegistration
|
|
| { light: ThemeRegistration; dark: ThemeRegistration };
|
|
|
|
const highLightCode = async (code: string, lang: string, active?: boolean) => {
|
|
const highlighter = await createHighlighter({
|
|
themes: ['github-light', 'github-dark'],
|
|
langs: Object.keys(bundledLanguages),
|
|
});
|
|
|
|
const highlightedCode = highlighter
|
|
.codeToHtml(code, {
|
|
lang,
|
|
themes: {
|
|
light: 'github-light',
|
|
dark: 'github-dark',
|
|
},
|
|
defaultColor: false,
|
|
})
|
|
.replace('shiki-themes', 'shiki-themes vp-code');
|
|
|
|
return `<div class="language-${lang} ${active ? 'active' : ''}">
|
|
<button title="Copy Code" class="copy"></button>
|
|
<span class="lang">${lang}</span>
|
|
${highlightedCode}
|
|
</div>`;
|
|
};
|
|
|
|
export default highLightCode;
|