2023-03-15 05:08:22 +08:00
|
|
|
import adapter from '@sveltejs/adapter-auto';
|
2023-12-17 01:07:44 +08:00
|
|
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
2023-03-15 05:08:22 +08:00
|
|
|
|
2023-12-14 07:42:17 +08:00
|
|
|
// Extensions:
|
|
|
|
import { mdsvex, escapeSvelte } from 'mdsvex';
|
2024-08-21 02:28:35 +08:00
|
|
|
import { createHighlighter, makeSingletonHighlighter } from 'shiki';
|
|
|
|
|
|
|
|
const getHighlighter = makeSingletonHighlighter(createHighlighter);
|
2023-12-14 07:42:17 +08:00
|
|
|
|
|
|
|
// Markdown config:
|
|
|
|
/** @type {import('mdsvex').MdsvexOptions} */
|
|
|
|
const mdsvexOptions = {
|
|
|
|
extensions: ['.md'],
|
|
|
|
highlight: {
|
|
|
|
highlighter: async (code, lang = 'text') => {
|
2024-03-09 20:46:38 +08:00
|
|
|
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' }));
|
2023-12-14 07:42:17 +08:00
|
|
|
return `{@html \`${html}\` }`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Svelte config:
|
2023-03-15 05:08:22 +08:00
|
|
|
/** @type {import('@sveltejs/kit').Config} */
|
|
|
|
const config = {
|
2023-12-14 07:42:17 +08:00
|
|
|
extensions: ['.svelte', '.md'],
|
|
|
|
preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)],
|
2023-03-15 19:29:15 +08:00
|
|
|
kit: {
|
2023-03-19 22:53:31 +08:00
|
|
|
adapter: adapter(),
|
|
|
|
alias: {
|
2023-12-14 07:42:17 +08:00
|
|
|
'@': './src/*'
|
2023-03-19 22:53:31 +08:00
|
|
|
}
|
2023-03-15 19:29:15 +08:00
|
|
|
}
|
2023-03-15 05:08:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default config;
|