webzone/plugins.ts
Sam Therapy fac5874be3
Some checks failed
Publish / build (push) Has been cancelled
Update template
Signed-off-by: Sam Therapy <sam@samtherapy.net>
2024-12-22 15:57:25 +01:00

31 lines
1 KiB
TypeScript

import "lume/types.ts";
import Color from "npm:colorjs.io@0.5.2";
import simpleIcons from "https://deno.land/x/lume_icon_plugins@v0.1.1/simpleicons.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";
/** 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())
.copy("static", ".");
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.copy([".jpg", ".webp", ".png"]);
};
}