-
Notifications
You must be signed in to change notification settings - Fork 7
/
_config.ts
133 lines (126 loc) Β· 3.8 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
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
132
133
import lume from "lume/mod.ts";
import markdown from "lume/plugins/markdown.ts";
import jsx from "lume/plugins/jsx_preact.ts";
import sass from "lume/plugins/sass.ts";
import postcss from "lume/plugins/postcss.ts";
import transformImages from "lume/plugins/transform_images.ts";
import picture from "lume/plugins/picture.ts";
import katex from "./_plugins/katex.ts";
import metas from "lume/plugins/metas.ts";
import resolveUrls from "lume/plugins/resolve_urls.ts";
import codeHighlight from "./_plugins/shiki.ts";
import sitemap from "lume/plugins/sitemap.ts";
import inline from "lume/plugins/inline.ts";
import pagefind from "lume/plugins/pagefind.ts";
import { linkInsideHeader } from "lume_markdown_plugins/toc/anchors.ts";
import toc from "lume_markdown_plugins/toc.ts";
import esbuild from "lume/plugins/esbuild.ts";
import { AsciidoctorEngine, asciidocLoader } from "./_plugins/asciidoc.ts";
import { default as markdownItAlerts } from "npm:markdown-it-github-alerts";
import modules from "lume/plugins/modules.ts";
import finder from "./_plugins/finder.ts";
const site = lume({
dest: "public/",
location: new URL("https://fi.cafour.cz"),
});
site
.ignore("readme.md", "contributing.md", "public", "deps.ts", "_plugins")
.use(markdown({
plugins: [[markdownItAlerts, {
titles: {
"tip": "",
"note": "",
"important": "",
"warning": "",
"caution": ""
},
icons: {
"tip": " ",
"note": " ",
"important": " ",
"warning": " ",
"caution": " "
},
classPrefix: "alert"
}]]
}))
.use(toc({
tabIndex: false,
// anchor: false,
anchor: linkInsideHeader({
placement: "before"
})
}))
.use(jsx())
.use(sass())
.use(postcss())
.use(metas())
.use(resolveUrls())
.use(sitemap({
query: "indexable=true"
}))
.use(inline())
.use(picture())
.use(transformImages({
extensions: [".png", ".jpg", ".jpeg", ".gif"],
functions: {
async resizeCrop(img, size) {
const metadata = await img.metadata();
let width = -1;
let height = -1;
if (typeof (size) == "number") {
width = size;
height = size;
}
else {
width = size[0];
height = size[1];
}
if (metadata.width! < metadata.height!) {
img.resize(width, null);
} else {
img.resize(null, height);
}
img.extract({
width: width,
height: height,
left: Math.floor((metadata.width! - width) / 2),
top: Math.floor((metadata.height! - height) / 2)
});
}
}
}))
.use(katex({
options: {
fleqn: true,
throwOnError: false,
output: "html",
strict: false
}
}))
.use(await codeHighlight())
.use(esbuild({
options: {
bundle: true,
format: "iife",
minify: false,
platform: "browser",
target: "esnext",
entryPoints: ["./scripts/main.ts"],
globalName: "fi"
}
}))
.loadPages([".ad"], { loader: asciidocLoader, engine: new AsciidoctorEngine() })
.copy([".svg"])
.copy("fonts")
.copy("icons")
.use(finder())
.use(pagefind({
indexing: {
rootSelector: "main"
},
ui: {
showSubResults: true
}
}));
export default site;