2023-12-17 01:07:44 +08:00
|
|
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
2023-03-15 05:08:22 +08:00
|
|
|
|
2024-09-23 17:47:26 +08:00
|
|
|
// ☁️ Adapter:
|
2024-09-27 20:34:47 +08:00
|
|
|
import adapter from '@sveltejs/adapter-node';
|
2024-09-23 17:47:26 +08:00
|
|
|
|
|
|
|
// 📦 Extensions:
|
2023-12-14 07:42:17 +08:00
|
|
|
import { mdsvex, escapeSvelte } from 'mdsvex';
|
2024-08-21 02:28:35 +08:00
|
|
|
import { createHighlighter, makeSingletonHighlighter } from 'shiki';
|
|
|
|
|
2024-10-01 17:49:43 +08:00
|
|
|
// 🎨 Markdown Plugins:
|
|
|
|
import remarkGfm from 'remark-gfm';
|
|
|
|
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
|
|
|
|
import rehypeSlug from 'rehype-slug';
|
|
|
|
|
2024-09-23 17:47:26 +08:00
|
|
|
// 📄 Markdown config:
|
2024-08-21 02:28:35 +08:00
|
|
|
const getHighlighter = makeSingletonHighlighter(createHighlighter);
|
2023-12-14 07:42:17 +08:00
|
|
|
|
|
|
|
/** @type {import('mdsvex').MdsvexOptions} */
|
|
|
|
const mdsvexOptions = {
|
2024-10-01 17:49:43 +08:00
|
|
|
remarkPlugins: [[remarkGfm]],
|
|
|
|
rehypePlugins: [
|
|
|
|
[rehypeSlug],
|
|
|
|
[
|
|
|
|
rehypeAutolinkHeadings,
|
|
|
|
{
|
|
|
|
behavior: 'wrap',
|
|
|
|
properties: {
|
|
|
|
className: [
|
|
|
|
`before:content-['#'] before:absolute before:-ml-[1em] before:text-neutral-100/0 hover:before:text-neutral-200/50 pl-[1em] -ml-[1em]`
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
],
|
2023-12-14 07:42:17 +08:00
|
|
|
extensions: ['.md'],
|
|
|
|
highlight: {
|
|
|
|
highlighter: async (code, lang = 'text') => {
|
2024-03-09 20:46:38 +08:00
|
|
|
const highlighter = await getHighlighter({
|
2024-10-01 16:25:30 +08:00
|
|
|
themes: ['vesper'],
|
2024-03-09 20:46:38 +08:00
|
|
|
langs: ['javascript', 'typescript', 'bash', 'json']
|
|
|
|
});
|
|
|
|
await highlighter.loadLanguage('javascript', 'typescript', 'bash');
|
2024-10-01 16:25:30 +08:00
|
|
|
const html = escapeSvelte(highlighter.codeToHtml(code, { lang, theme: 'vesper' }));
|
2023-12-14 07:42:17 +08:00
|
|
|
return `{@html \`${html}\` }`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-09-27 20:34:47 +08:00
|
|
|
// 🧡 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;
|