Foster Hangdaan
28839e99bf
The new processor appends the `docstring` class to code docstrings so that they can be styled.
81 lines
2.2 KiB
TypeScript
81 lines
2.2 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 "https://deno.land/x/lume_markdown_plugins@v0.6.0/toc.ts";
|
|
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";
|
|
|
|
const site = lume({
|
|
location: new URL("https://www.fosterhangdaan.com/"),
|
|
server: {
|
|
port: 8080,
|
|
},
|
|
});
|
|
|
|
site.ignore("README.md", "README.org", "LICENSE.txt", "LICENSE.md");
|
|
|
|
site.copy("static", ".");
|
|
|
|
site.copy([".png", ".jpg", ".jpeg"]);
|
|
|
|
site.use(jsx());
|
|
site.use(nav());
|
|
site.use(sass());
|
|
site.use(feed({
|
|
query: "type=post",
|
|
output: [
|
|
"/blog/feed.rss",
|
|
"/blog/feed.json",
|
|
],
|
|
info: {
|
|
title: "Foster Hangdaan's Blog",
|
|
description: "My thoughts and ideas.",
|
|
date: new Date(),
|
|
lang: "en",
|
|
},
|
|
items: {
|
|
title: "=title",
|
|
description: "=description",
|
|
}
|
|
}));
|
|
site.use(code_highlight({
|
|
languages: {
|
|
typescript: lang_typescript,
|
|
javascript: lang_javascript,
|
|
bash: lang_bash,
|
|
}
|
|
}));
|
|
site.use(toc({
|
|
slugify: {
|
|
separator: "-",
|
|
lowercase: true,
|
|
},
|
|
}));
|
|
site.use(footnotes());
|
|
|
|
site.process([".html"], (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.
|
|
const codeCommentElements = page.document?.getElementsByClassName("hljs-comment");
|
|
if (codeCommentElements && codeCommentElements.length > 0) {
|
|
const docStringRegex = /^\/\*\*.*\*\/$/gsm;
|
|
const codeDocStringElements = codeCommentElements.filter((el) => {
|
|
const matchResult = el.innerText.match(docStringRegex);
|
|
return !!matchResult;
|
|
});
|
|
if (codeDocStringElements.length > 0) {
|
|
codeDocStringElements.forEach((el) => {
|
|
el.classList.add("docstring");
|
|
})
|
|
}
|
|
}
|
|
});
|
|
|
|
export default site;
|