forked from hideckies/exploit-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_config.ts
103 lines (94 loc) · 2.88 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
import lume from "lume/mod.ts";
import date from "lume/plugins/date.ts";
import codeHighlight from "lume/plugins/code_highlight.ts";
import basePath from "lume/plugins/base_path.ts";
import slugifyUrls from "lume/plugins/slugify_urls.ts";
import resolveUrls from "lume/plugins/resolve_urls.ts";
import pagefind from "lume/plugins/pagefind.ts";
import sitemap from "lume/plugins/sitemap.ts";
import toc from "https://deno.land/x/[email protected]/toc/mod.ts";
import tailwindcss from "lume/plugins/tailwindcss.ts";
import postcss from "lume/plugins/postcss.ts";
import codecopy from "./codecopy.ts";
const markdown = {
plugins: [toc],
keepDefaultPlugins: true,
};
const site = lume({
location: new URL("https://exploit-notes.hdks.org"),
src: "./src",
dest: "./_site",
emptyDest: true,
prettyUrls: true,
server: {
port: 3000,
page404: "/404",
open: false,
},
watcher: {
debounce: 1000,
},
},
{ markdown });
site
.ignore("README.md")
.copy("assets", ".")
.use(date())
.use(codeHighlight())
.use(basePath())
.use(slugifyUrls({ alphanumeric: false }))
.use(resolveUrls())
.use(pagefind({
ui: {
containerId: "search",
showImages: false,
showEmptyFilters: true,
resetStyles: true,
},
}))
.use(sitemap())
.use(tailwindcss({
options: {
theme: {
fontFamily: {
base: ["Calibri, sans-serif"],
title: ["courier"],
}
}
}
}))
.use(postcss())
.use(codecopy());
site.helper("titlize", (text: string) => {
const tSplit = text.split(/[\-\_]/g);
return tSplit.map((t: string) => {
const newT = [...t];
newT[0] = newT[0].toUpperCase();
return newT.join("");
}).join(" ");
}, { type: "filter" });
site.process([".html"], (pages: Lume.Page[]) => {
// Add "On This Page" in the right pane for each exploit page.
pages.forEach((page: Lume.Page) => {
if (page.data.type === "exploit" && page.document) {
const tocElem = page.document.querySelector(".toc");
if (tocElem) {
page.data.toc.forEach((c: any) => {
if (c.level === 2) {
if (page.document) {
const aElem = page.document.createElement('a');
aElem.setAttribute("href", `#${c.slug}`);
aElem.innerHTML = c.text;
aElem.classList.add('text-base');
aElem.classList.add('text-slate-400');
aElem.classList.add('break-words');
// Add to the parent element
tocElem.appendChild(aElem);
}
}
});
}
}
});
});
export default site;