-
Notifications
You must be signed in to change notification settings - Fork 0
/
_config.ts
116 lines (93 loc) · 3.22 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
import lume from "lume/mod.ts";
import { sort } from "meta";
import footnote from "https://jspm.dev/[email protected]";
const site = lume({
location: new URL("https://aiotter.com"),
}, {
markdown: {
plugins: [footnote],
keepDefaultPlugins: true,
},
});
const md = site.formats.get(".md")!.engine;
// @ts-ignore: no type information
md.engine.renderer.rules.footnote_block_open = () => (
'<section class="footnotes" data-footnotes>' +
'<h2 class="sr-only" id="footnote-label">Footnotes</h2>' +
'<ol class="list-decimal list-outside">'
);
// @ts-ignore: no type information
md.engine.renderer.rules.footnote_block_close = () => (
"</ol></section>"
);
// @ts-ignore: no type information
md.engine.renderer.rules.footnote_caption = (tokens, idx) => {
let n = Number(tokens[idx].meta.id + 1).toString();
if (tokens[idx].meta.subId > 0) {
n += ":" + tokens[idx].meta.subId;
}
return n;
};
import codeHighlight from "lume/plugins/code_highlight.ts";
site.use(codeHighlight());
import resolveUrls from "lume/plugins/resolve_urls.ts";
site.use(resolveUrls());
import svgo from "lume/plugins/svgo.ts";
site.use(svgo());
import terser from "lume/plugins/terser.ts";
site.use(terser());
import nanoJsx, { NanoJsxEngine } from "plugins/nano-jsx.tsx";
site.use(nanoJsx({ importMap: new URL("import_map.json", import.meta.url) }));
import mdx from "plugins/mdx.ts";
import * as runtime from "nano/jsx-runtime";
site.use(
mdx({
mdxOptions: { ...runtime, useDynamicImport: true },
jsxEngine: new NanoJsxEngine(),
}),
);
import dateFromGit from "plugins/date-from-git.ts";
site.use(dateFromGit());
import history from "plugins/history.ts";
site.use(history());
import asciidoc from "plugins/asciidoctor-js.ts";
site.use(asciidoc());
import tailwindcss from "plugins/tailwindcss.ts";
site.use(tailwindcss());
import sass from "https://raw.githubusercontent.com/lumeland/experimental-plugins/a10a8bbf353674ab30c611185553a82ed6ada71e/sass/sass.ts";
site.use(sass());
// Auto generate CSS files
import moduleLoader from "lume/core/loaders/module.ts";
site.loadAssets([".css.ts"], moduleLoader);
site.process([".css.ts"], (page) => page.dest.ext = ".css");
import autoTitle from "plugins/auto-title.ts";
site.use(autoTitle());
site.preprocess(
"*",
(page) => page.data.sourceFile = page.src.path + page.src.ext ?? "",
);
site.preprocess(
"*",
(page) => page.data.tags = page.data.tags?.map((tag) => tag.toLowerCase()),
);
// Set collection-page type for pages which use "collection" layout
site.preprocess([".html"], (page) => {
if (
page.data.layout === "layouts/collection.tsx" ||
page.data.type === "collection"
) {
page.data.type = "collection";
const collectionPages = [...page.parent!.pages.values()]
.filter((page) => page.data.type !== "collection")
.sort(sort.pages.dateDescending);
const newestPage = collectionPages[0];
page.data.lastModified = newestPage.data.lastModified;
// Set collection-page type for pages in the same directory as collection page
collectionPages.forEach((collectionPage) => {
collectionPage.data.type = "collection-page";
collectionPage.data.collection = page.data.sourceFile;
});
}
});
site.loadAssets([".css"]);
export default site;