Skip to content

Commit

Permalink
fix: Update Shiki and Svelte plugin for Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcroat committed Feb 10, 2024
1 parent 8ff9ed0 commit b965255
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import adapter from '@sveltejs/adapter-vercel'
import { vitePreprocess } from '@sveltejs/kit/vite'
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'

import { mdsvex, escapeSvelte } from 'mdsvex'
import shiki from 'shiki'
import {getHighlighter } from 'shiki'
import remarkUnwrapImages from 'remark-unwrap-images'
import remarkToc from 'remark-toc'
import rehypeSlug from 'rehype-slug'
Expand All @@ -15,9 +15,13 @@ const mdsvexOptions = {
},
highlight: {
highlighter: async (code, lang = 'text') => {
const highlighter = await shiki.getHighlighter({ theme: 'poimandres' })
const html = escapeSvelte(highlighter.codeToHtml(code, { lang }))
return `{@html \`${html}\` }`
const highlighter = await getHighlighter({
themes: ['poimandres'],
langs: ['javascript', 'typescript']
});
await highlighter.loadLanguage('javascript', 'typescript');
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme: 'poimandres' }));
return `{@html \`${html}\` }`;
}
},
remarkPlugins: [remarkUnwrapImages, [remarkToc, { tight: true }]],
Expand Down

0 comments on commit b965255

Please sign in to comment.