Chrysoblog/svelte.config.js

86 lines
2.3 KiB
JavaScript
Raw Normal View History

2024-09-11 00:51:05 -07:00
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import adapter from '@sveltejs/adapter-static';
2024-09-17 13:09:08 -07:00
2024-10-15 13:58:14 -07:00
import { mdsvex, escapeSvelte } from 'mdsvex';
2024-09-17 13:09:08 -07:00
import remarkAlert from './src/lib/markdown.js'
import relativeImages from 'mdsvex-relative-images'
import remarkToc from 'remark-toc'
import rehypeSlug from 'rehype-slug'
2024-10-15 13:58:14 -07:00
import { getHighlighter } from 'shiki'
2024-09-11 00:51:05 -07:00
const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content";
2024-09-14 18:06:29 -07:00
2024-10-15 18:59:02 -07:00
const langs = [
"rust",
"nix",
"python",
"lean",
"javascript",
"typescript",
];
const highlightingThemes = {
2024-10-15 19:14:27 -07:00
light: 'vitesse-light',
dark: 'vitesse-dark',
2024-10-15 18:59:02 -07:00
};
2024-09-11 00:51:05 -07:00
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [
2024-09-14 00:59:54 -07:00
mdsvex({
extensions: ['.md'],
remarkPlugins: [
remarkAlert,
relativeImages,
[remarkToc, {tight: true}],
],
rehypePlugins: [
rehypeSlug,
2024-10-15 13:58:14 -07:00
],
highlight: {
highlighter: async (code, lang = 'text') => {
2024-10-15 18:59:02 -07:00
const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] });
2024-10-15 13:58:14 -07:00
const highlighter = await getHighlighter({
2024-10-15 18:59:02 -07:00
themes,
langs,
2024-10-15 13:58:14 -07:00
})
2024-10-15 18:59:02 -07:00
await highlighter.loadLanguage(...langs);
const html = escapeSvelte(highlighter.codeToHtml(code, {
lang,
themes: highlightingThemes,
}))
2024-10-15 13:58:14 -07:00
return `{@html \`${html}\` }`
}
},
}),
2024-09-17 13:09:08 -07:00
vitePreprocess(),
],
extensions: [".svelte", ".md"],
2024-09-11 00:51:05 -07:00
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
2024-09-26 23:02:46 -07:00
adapter: adapter({
pages: "build",
assets: "build",
fallback: null,
precompress: false,
trailingSlash: 'always',
}),
2024-09-29 18:45:35 -07:00
prerender: {
crawl: true,
entries: [
"/page/1/",
],
},
2024-09-11 07:54:39 -07:00
alias: {
2024-09-14 18:06:29 -07:00
$content: contentDir,
"@/*": "./*",
2024-09-11 07:54:39 -07:00
},
2024-09-11 00:51:05 -07:00
}
};
export default config;