1 Star 0 Fork 0

wangzhefeng2000/svgl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
svelte.config.js 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
Pablo Hdez 提交于 2025-03-19 17:29 +08:00 . ⚙️ Move to adapter auto in svelte.config
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
// ☁️ Adapter:
import adapter from '@sveltejs/adapter-auto';
// 📦 Extensions:
import { mdsvex, escapeSvelte } from 'mdsvex';
import { createHighlighter, makeSingletonHighlighter } from 'shiki';
// 🎨 Markdown Plugins:
import remarkGfm from 'remark-gfm';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
// 📄 Markdown config:
const getHighlighter = makeSingletonHighlighter(createHighlighter);
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
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]`
]
}
}
]
],
extensions: ['.md'],
highlight: {
highlighter: async (code, lang = 'text') => {
const highlighter = await getHighlighter({
themes: ['github-light', 'github-dark'],
langs: ['javascript', 'typescript', 'bash', 'json']
});
await highlighter.loadLanguage('javascript', 'typescript', 'bash');
const html = escapeSvelte(
highlighter.codeToHtml(code, {
lang,
themes: {
light: 'github-light',
dark: 'github-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;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangzhefeng2000/svgl.git
git@gitee.com:wangzhefeng2000/svgl.git
wangzhefeng2000
svgl
svgl
main

搜索帮助