website/_config.ts

106 lines
2.6 KiB
TypeScript
Raw Normal View History

2023-07-23 16:04:28 -04:00
import lume from "lume/mod.ts";
import jsx from "lume/plugins/jsx.ts";
import nav from "lume/plugins/nav.ts";
import sass from "lume/plugins/sass.ts";
2023-08-05 20:13:10 -04:00
import feed from "lume/plugins/feed.ts";
import code_highlight from "lume/plugins/code_highlight.ts";
2024-09-06 11:05:02 -04:00
import toc from "lume-markdown-plugins/toc.ts";
import footnotes from "lume-markdown-plugins/footnotes.ts";
2024-11-08 18:03:58 -05:00
import kroki from "https://code.fosterhangdaan.com/foster/lume-plugin-kroki/raw/tag/v1.0.1/mod.ts";
import lang_typescript from "npm:highlight.js/lib/languages/typescript";
import lang_javascript from "npm:highlight.js/lib/languages/javascript";
import lang_bash from "npm:highlight.js/lib/languages/bash";
2023-07-23 16:04:28 -04:00
const site = lume({
2024-09-10 07:01:50 -04:00
src: "./src",
2023-08-05 20:13:10 -04:00
location: new URL("https://www.fosterhangdaan.com/"),
2023-07-23 16:04:28 -04:00
});
2023-10-02 19:41:35 -04:00
site.ignore("README.md", "README.org", "LICENSE.txt", "LICENSE.md");
2023-07-23 16:21:17 -04:00
2024-09-10 07:30:23 -04:00
site.copy("static", ".");
site.copy([
".avif",
".jpeg",
".jpg",
".png",
".webp",
]);
2023-11-28 16:19:58 -05:00
2023-07-23 16:04:28 -04:00
site.use(jsx());
site.use(nav());
site.use(sass());
2023-08-05 20:13:10 -04:00
site.use(feed({
query: "type=post",
output: [
"/blog/feed.rss",
"/blog/feed.json",
],
info: {
2024-11-06 18:07:12 -05:00
authorName: "=site.author.name",
authorUrl: "=site.author.url",
description: "A strange place where I write something other than code.",
2023-08-06 16:45:45 -04:00
lang: "en",
2024-11-06 18:07:12 -05:00
published: new Date(),
title: "Foster Hangdaan's Blog",
2023-08-05 20:13:10 -04:00
},
items: {
2024-11-06 18:07:12 -05:00
authorName: "=author.name",
authorUrl: "=author.url",
2023-08-05 20:13:10 -04:00
description: "=description",
2023-12-09 10:45:00 -05:00
published: "=date",
2024-11-06 18:07:12 -05:00
title: "=title",
2023-12-09 10:45:00 -05:00
updated: "=updated",
2024-03-05 18:38:42 -05:00
},
2023-08-05 20:13:10 -04:00
}));
site.use(code_highlight({
languages: {
typescript: lang_typescript,
javascript: lang_javascript,
bash: lang_bash,
2024-03-05 18:38:42 -05:00
},
options: {
noHighlightRe: /^no-highlight$/i,
languageDetectRe: /\blanguage-([\w-]+)\b/i,
classPrefix: "hljs-",
cssSelector: "pre code",
},
}));
site.use(toc({
slugify: {
separator: "-",
lowercase: true,
},
}));
2023-12-03 13:11:01 -05:00
site.use(footnotes());
2024-11-08 17:02:47 -05:00
site.use(kroki({
server: "https://kroki.fosterhangdaan.com",
}));
2023-07-23 16:04:28 -04:00
2023-12-09 10:45:00 -05:00
site.process([".html"], (pages) => {
pages.forEach((page) => {
2024-09-06 11:05:02 -04:00
if (page.document) {
2024-09-14 08:29:15 -04:00
// NOTE: This is a hack to append a class to JS doctrings so that we
// can style them. If only the Hightlight.js plugin could be configured
// to do this instead.
2024-09-06 11:05:02 -04:00
for (
const codeCommentElement of page.document.getElementsByClassName(
"hljs-comment",
)
) {
2024-03-05 18:38:42 -05:00
const docStringRegex = /^\/\*\*.*\*\/$/gsm;
2024-09-06 11:05:02 -04:00
const matchResult = codeCommentElement.textContent?.match(
docStringRegex,
);
2024-03-05 18:38:42 -05:00
if (matchResult) {
codeCommentElement.classList.add("docstring");
}
2024-09-06 11:05:02 -04:00
}
}
2023-12-05 10:36:20 -05:00
});
});
2023-07-23 16:04:28 -04:00
export default site;