forked from KlasenK/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvelte.config.js
131 lines (126 loc) · 3.72 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import adapterNetlify from "@sveltejs/adapter-netlify";
import { mdsvex } from "mdsvex";
import headings from "remark-autolink-headings";
import remarkExternalLinks from "remark-external-links";
import slug from "remark-slug";
import preprocess from "svelte-preprocess";
import remarkSetImagePath from "./src/lib/utils/remark-set-image-path.js";
import remarkEmbedVideo from "./src/lib/utils/remark-embed-video.js";
import remarkLinkWithImageAsOnlyChild from "./src/lib/utils/remark-link-with-image-as-only-child.js";
import remarkHeadingsPermaLinks from "./src/lib/utils/remark-headings-permalinks.js";
import { toString } from "mdast-util-to-string";
import rehypeWrap from "rehype-wrap-all";
import rehypeImgSize from "rehype-img-size";
import { highlightCode } from "./src/lib/utils/highlight.js";
import { mdsvexGlobalComponents } from "./src/lib/utils/mdsvex-global-components.js";
import { h } from "hastscript";
import { visit } from "unist-util-visit";
/** @type {Partial<import('vite').ServerOptions>} */
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: [".svelte", ".md"],
compilerOptions: {
hydratable: true,
},
kit: {
browser: {
hydrate: true,
router: true,
},
trailingSlash: "never",
adapter: adapterNetlify({
edge: false,
split: false,
}),
files: {
assets: "static",
hooks: "src/hooks",
lib: "src/lib",
routes: "src/routes",
template: "src/app.html",
},
prerender: {
crawl: true,
enabled: true,
onError: "fail", //once the netlify-endpoint for requesting the images isn't needed anymore this can be "fail" again
entries: ["*"],
},
},
// options passed to svelte.preprocess (https://svelte.dev/docs#svelte_preprocess)
preprocess: [
preprocess({
postcss: true,
scss: true,
preserve: ["ld+json"],
}),
mdsvexGlobalComponents({
dir: `$lib/components`,
list: [["CodeFence", "code-fence.svelte"]],
extensions: [".md"],
}),
mdsvex({
extensions: [".md"],
highlight: {
highlighter: highlightCode,
},
layout: {
blog: "./src/lib/components/blog/blog-content-layout.svelte",
docs: "./src/lib/components/docs/docs-content-layout.svelte",
guides: "./src/lib/components/guides/guides-content-layout.svelte",
customers:
"./src/lib/components/customers/customers-content-layout.svelte",
},
rehypePlugins: [
[rehypeWrap, { selector: "table", wrapper: "div.overflow-auto" }],
[rehypeImgSize, { dir: "./static" }],
[
/** Custom rehype plugin to add loading="lazy" to all images */
() => {
return (tree) => {
visit(tree, "element", (node) => {
if (node.tagName === "img") {
node.properties.loading = "lazy";
}
});
};
},
],
],
remarkPlugins: [
[
remarkExternalLinks,
{
target: "_blank",
},
],
slug,
[
headings,
{
behavior: "append",
linkProperties: {},
content: function (node) {
return [
h("span.icon.icon-link header-anchor", {
ariaLabel: toString(node) + " permalink",
}),
];
},
},
],
remarkSetImagePath,
remarkLinkWithImageAsOnlyChild,
remarkHeadingsPermaLinks,
[
remarkEmbedVideo,
{
width: 800,
height: 400,
noIframeBorder: true,
},
],
],
}),
],
};
export default config;