-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.ts
50 lines (45 loc) · 1.62 KB
/
plugins.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
import "lume/types.ts";
// import Color from "https://colorjs.io/dist/color.js";
import Color from "npm:colorjs.io";
import simpleIcons from "https://deno.land/x/[email protected]/simpleicons.ts";
import icons from "lume/plugins/icons.ts"
import basePath from "lume/plugins/base_path.ts";
import favicon from "lume/plugins/favicon.ts";
import metas from "lume/plugins/metas.ts";
import postcss from "lume/plugins/postcss.ts";
import transformImages from "lume/plugins/transform_images.ts";
import prism from "lume/plugins/prism.ts";
import date from "lume/plugins/date.ts";
import { getGitDate } from "lume/core/utils/date.ts";
import { enUS } from "npm:date-fns/locale/en-US";
import { ja } from "npm:date-fns/locale/ja";
/** Configure the site */
export default function () {
return (site: Lume.Site) => {
site.use(postcss())
.use(metas())
.use(favicon())
.use(basePath())
.mergeKey("extra_head", "stringArray")
.use(transformImages())
.use(simpleIcons())
.use(icons())
.use(prism())
.use(date({ locales: { enUS, ja } }));
site.data("textColor", (hex: string) => {
const color = new Color(`#${hex}`);
const onWhite = Math.abs(color.contrastWCAG21("white"));
const onBlack = Math.abs(color.contrastWCAG21("black"));
return (onWhite + 0.5) > onBlack ? "white" : "black";
});
site.preprocess([".html"], (pages) => {
for (const page of pages) {
const src = page.src.entry?.src;
if (src) {
page.data.lastmod = getGitDate("modified", src);
}
}
});
site.copy([".jpg", ".webp", ".png", ".svg"]);
};
}