105 lines
2.6 KiB
TypeScript
105 lines
2.6 KiB
TypeScript
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";
|
|
import feed from "lume/plugins/feed.ts";
|
|
import code_highlight from "lume/plugins/code_highlight.ts";
|
|
import toc from "lume-markdown-plugins/toc.ts";
|
|
import footnotes from "lume-markdown-plugins/footnotes.ts";
|
|
import kroki from "https://code.fosterhangdaan.com/foster/lume-plugin-kroki/raw/tag/v1.0.0/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";
|
|
|
|
const site = lume({
|
|
src: "./src",
|
|
location: new URL("https://www.fosterhangdaan.com/"),
|
|
});
|
|
|
|
site.ignore("README.md", "README.org", "LICENSE.txt", "LICENSE.md");
|
|
|
|
site.copy("static", ".");
|
|
|
|
site.copy([
|
|
".avif",
|
|
".jpeg",
|
|
".jpg",
|
|
".png",
|
|
".webp",
|
|
]);
|
|
|
|
site.use(jsx());
|
|
site.use(nav());
|
|
site.use(sass());
|
|
site.use(feed({
|
|
query: "type=post",
|
|
output: [
|
|
"/blog/feed.rss",
|
|
"/blog/feed.json",
|
|
],
|
|
info: {
|
|
authorName: "=site.author.name",
|
|
authorUrl: "=site.author.url",
|
|
description: "A strange place where I write something other than code.",
|
|
lang: "en",
|
|
published: new Date(),
|
|
title: "Foster Hangdaan's Blog",
|
|
},
|
|
items: {
|
|
authorName: "=author.name",
|
|
authorUrl: "=author.url",
|
|
description: "=description",
|
|
published: "=date",
|
|
title: "=title",
|
|
updated: "=updated",
|
|
},
|
|
}));
|
|
site.use(code_highlight({
|
|
languages: {
|
|
typescript: lang_typescript,
|
|
javascript: lang_javascript,
|
|
bash: lang_bash,
|
|
},
|
|
options: {
|
|
noHighlightRe: /^no-highlight$/i,
|
|
languageDetectRe: /\blanguage-([\w-]+)\b/i,
|
|
classPrefix: "hljs-",
|
|
cssSelector: "pre code",
|
|
},
|
|
}));
|
|
site.use(toc({
|
|
slugify: {
|
|
separator: "-",
|
|
lowercase: true,
|
|
},
|
|
}));
|
|
site.use(footnotes());
|
|
site.use(kroki({
|
|
server: "https://kroki.fosterhangdaan.com",
|
|
}));
|
|
|
|
site.process([".html"], (pages) => {
|
|
pages.forEach((page) => {
|
|
if (page.document) {
|
|
// 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.
|
|
for (
|
|
const codeCommentElement of page.document.getElementsByClassName(
|
|
"hljs-comment",
|
|
)
|
|
) {
|
|
const docStringRegex = /^\/\*\*.*\*\/$/gsm;
|
|
const matchResult = codeCommentElement.textContent?.match(
|
|
docStringRegex,
|
|
);
|
|
if (matchResult) {
|
|
codeCommentElement.classList.add("docstring");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
export default site;
|