svgl/svelte.config.js
2024-03-09 12:46:38 +00:00

39 lines
1.0 KiB
JavaScript

import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
// Extensions:
import { mdsvex, escapeSvelte } from 'mdsvex';
import { getHighlighter } from 'shiki';
// Markdown config:
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
extensions: ['.md'],
highlight: {
highlighter: async (code, lang = 'text') => {
const highlighter = await getHighlighter({
themes: ['vitesse-dark'],
langs: ['javascript', 'typescript', 'bash', 'json']
});
await highlighter.loadLanguage('javascript', 'typescript', 'bash');
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme: 'vitesse-dark' }));
return `{@html \`${html}\` }`;
}
}
};
// Svelte config:
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte', '.md'],
preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)],
kit: {
adapter: adapter(),
alias: {
'@': './src/*'
}
}
};
export default config;