-
Notifications
You must be signed in to change notification settings - Fork 1
/
_config.js
92 lines (77 loc) · 2.26 KB
/
_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
import lume from "lume/mod.ts";
import date from "lume/plugins/date.ts";
import slugifyUrls from "lume/plugins/slugify_urls.ts";
import binaryLoader from "lume/core/loaders/binary.ts";
import postcss from "lume/plugins/postcss.ts";
import markdown from "lume/plugins/markdown.ts";
import nunjucks from "lume/plugins/nunjucks.ts";
import basic from "./_plugins/basic.js";
import esbuild from "./_plugins/esbuild.js";
import prism from "./_plugins/prism.js";
import forceJs from "./_plugins/force_js.js";
import NunjucksSVG from "./_plugins/nunjucks-svg.js";
import postcssCSSO from "https://esm.sh/postcss-csso";
import markdownItMathJaxTexSvg from "./_plugins/markdown-it-mathjax-texsvg.js";
import markdownItComponent from "./_plugins/markdown-it-component.js";
const dev = Deno.args.indexOf('--dev') != -1;
const site = lume({
watcher: {
debounce: 0,
}
}, {
verbose: 2,
nunjucks: {
options: {
autoescape: false
},
plugins: {
"svg": new NunjucksSVG(dev),
}
},
markdown: {
options: {
typographer: true,
},
plugins: [
markdownItComponent(),
markdownItMathJaxTexSvg({quick: dev}),
]
},
});
if (dev) {
site.options.location = new URL("https://dev.metaphora.co/bkc/_site");
} else {
site.options.location = new URL("https://canvas.rocks");
site.ignore("js/dev");
}
site.ignore("_images", "_plugins", "orig", "3rdp", ".gitignore", ".git",
"js/lib", "README.md", "TODO");
site.copy("assets", "assets");
site.loadAssets([".html"]);
site.loadAssets([".png"], binaryLoader);
site.loadAssets([".webp"], binaryLoader);
site.loadAssets([".webm"], binaryLoader);
// register `date` primitive on NJK.
site.use(date());
// clean up URLS to ASCII only.
site.use(slugifyUrls());
site.use(forceJs());
site.use(prism());
site.use(postcss({
plugins: [postcssCSSO()],
keepDefaultPlugins: true,
sourceMap: dev ? {inline: true} : false,
}));
site.use(basic());
site.use(esbuild());
// auto reload
const hasReload = (await Deno.run({ cmd: ["which", "chrome-reload"],
stdout: "null", stderr: "null" }).status()).success;
if (hasReload) {
console.log("has reload");
site.addEventListener("afterUpdate", ev => {
console.log("reload");
Deno.run({ cmd: ["chrome-reload", "reload"] });
});
}
export default site;