website/_config.ts

79 lines
2.1 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";
import toc from "https://deno.land/x/lume_markdown_plugins@v0.6.0/toc.ts";
2023-12-03 13:11:01 -05:00
import footnotes from "https://deno.land/x/lume_markdown_plugins@v0.6.0/footnotes.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({
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
site.copy("static", ".");
2023-11-28 16:19:58 -05:00
site.copy([".png", ".jpg", ".jpeg"]);
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: {
title: "Foster Hangdaan's Blog",
description: "My thoughts and ideas.",
2023-12-09 10:45:00 -05:00
published: new Date(),
2023-08-06 16:45:45 -04:00
lang: "en",
2023-08-05 20:13:10 -04:00
},
items: {
title: "=title",
description: "=description",
2023-12-09 10:45:00 -05:00
published: "=date",
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
},
}));
site.use(toc({
slugify: {
separator: "-",
lowercase: true,
},
}));
2023-12-03 13:11:01 -05:00
site.use(footnotes());
2023-07-23 16:04:28 -04:00
2023-12-09 10:45:00 -05:00
site.process([".html"], (pages) => {
pages.forEach((page) => {
// 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-03-05 18:38:42 -05:00
page.document?.getElementsByClassName("hljs-comment").forEach(
(codeCommentElement) => {
const docStringRegex = /^\/\*\*.*\*\/$/gsm;
const matchResult = codeCommentElement.innerText.match(docStringRegex);
if (matchResult) {
codeCommentElement.classList.add("docstring");
}
},
);
2023-12-05 10:36:20 -05:00
});
});
2023-07-23 16:04:28 -04:00
export default site;