forked from KlasenK/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
svelte.config.js
128 lines (124 loc) · 3.56 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
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 sveltePreprocess from "svelte-preprocess";
import rehypeToc from "@jsdevtools/rehype-toc";
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 { h } from "hastscript";
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: [".svelte", ".md"],
kit: {
adapter: adapterNetlify(),
amp: false,
appDir: "_app",
files: {
assets: "static",
hooks: "src/hooks",
lib: "src/lib",
routes: "src/routes",
template: "src/app.html",
},
hydrate: true,
prerender: {
crawl: true,
enabled: true,
onError: "fail",
entries: ["*"],
},
router: true,
ssr: true,
target: "#svelte",
vite: {
resolve: {
preserveSymlinks: true,
},
server: {
hmr: {
clientPort: process.env.HMR_HOST ? 443 : 3000,
host: process.env.HMR_HOST
? process.env.HMR_HOST.substring("https://".length)
: "localhost",
},
},
},
},
// options passed to svelte.preprocess (https://svelte.dev/docs#svelte_preprocess)
preprocess: [
sveltePreprocess({ postcss: true, scss: true, preserve: ["ld+json"] }),
mdsvex({
extensions: [".md"],
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",
},
rehypePlugins: [
[
rehypeToc,
{
customizeTOC: (toc) => {
// The Toc always has an <ol> element, but it doesn't
// have children if the Markdown content contains no headings.
return toc.children[0].children.length === 0 ? false : toc;
},
customizeTOCItem: (toc, heading) => {
if (heading.tagName !== "h2") {
toc.properties.className = `${
toc.properties.className || ""
} ml-4`;
}
return toc;
},
cssClasses: {
listItem: "toc-level my-micro",
},
headings: ["h2", "h3", "h4", "h5", "h6"],
position: "beforebegin",
},
],
],
remarkPlugins: [
[
remarkExternalLinks,
{
target: "_blank",
},
],
slug,
[
headings,
{
behavior: "append",
linkProperties: {},
content: function (node) {
return [
h("span.icon.icon-link", {
ariaLabel: toString(node) + " permalink",
}),
];
},
},
],
remarkSetImagePath,
remarkLinkWithImageAsOnlyChild,
remarkHeadingsPermaLinks,
[
remarkEmbedVideo,
{
width: 800,
height: 400,
noIframeBorder: true,
},
],
],
}),
],
};
export default config;