-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsvelte.config.js
76 lines (70 loc) · 1.66 KB
/
svelte.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import { mdsvex } from "mdsvex";
import { visit } from "unist-util-visit";
import rehypeTitleFigure from 'rehype-title-figure'
import smartypants from "remark-smartypants";
import classNames from "rehype-class-names";
const classNamesOptions = {
h2: "section",
h3: "subsection",
h4: "subsubsection",
a: "link",
figure: "figure"
};
const blogImages = () => {
return (tree, file) => {
visit(tree, "image", (node) => {
if (node.url.startsWith("./")) {
const route = file.filename
.split("routes")[1]
.split("/")
.slice(0, -1)
.join("/");
node.url = `${route}/${node.url.slice(2)}`;
}
});
};
};
const escapeQuotes = () => {
return (tree) => {
visit(tree, 'image', (node) => {
if (node.alt) {
node.alt = node.alt.replace(/"/g, '"');
}
});
};
}
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
extensions: [".md"],
remarkPlugins: [
smartypants,
escapeQuotes
],
rehypePlugins: [
blogImages,
rehypeTitleFigure,
[classNames, classNamesOptions],
],
layout: {
blog: "src/lib/blocks/Post.svelte",
},
};
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
prerender: {
handleHttpError: "warn",
handleMissingId: "warn",
entries: ["*"],
},
paths: {
base: process.env.NODE_ENV === "production" ? "" : "",
},
},
extensions: [".svelte", ".md"],
preprocess: [mdsvex(mdsvexOptions), vitePreprocess()],
};
export default config;