-
Notifications
You must be signed in to change notification settings - Fork 0
/
_config.ts
68 lines (62 loc) · 1.47 KB
/
_config.ts
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
import lume from "lume/mod.ts"
import jsx_preact from "lume/plugins/jsx_preact.ts"
import mdx from "lume/plugins/mdx.ts"
import shiki from "./plugins/shiki/mod.ts"
import HeadingsSlug from "npm:rehype-slug"
import AutolinksHeadings from "npm:rehype-autolink-headings"
import tailwindcss from "lume/plugins/tailwindcss.ts"
import postcss from "lume/plugins/postcss.ts"
import sitemap from "lume/plugins/sitemap.ts"
const site = lume({
src: "./src",
server: {
page404: "/404/index.html",
},
})
const plugins = [
jsx_preact(),
mdx({
rehypePlugins: [HeadingsSlug, AutolinksHeadings],
}),
shiki(),
tailwindcss({
extensions: [".html", ".tsx"],
// @ts-ignore false error
options: {
corePlugins: {
preflight: false,
},
},
}),
postcss(),
sitemap(),
]
plugins.forEach((plugin) => site.use(plugin))
site.process([".mdx"], (pages) => {
pages.forEach((page) => {
if (page.src.path.startsWith("/blog/")) {
page.document?.body?.querySelectorAll("a").forEach(
(el) => {
if (
// @ts-ignore ""
el.getAttribute("tabindex") == "-1" ||
["/", "/blog", "/portfolio", "#blog-footer"].includes(
// @ts-ignore ""
el.getAttribute("href"),
)
) { // @ts-ignore ""
el.setAttribute("target", "_self")
} else {
// @ts-ignore ""
el.setAttribute("target", "_blank")
}
},
)
}
})
})
site.copy("assets")
site.copy("server.ts")
site.copy("index.js")
site.copy("google960bff13302df6ac.html")
export default site