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.", published: new Date(), lang: "en", }, items: { title: "=title", description: "=description", published: "=date", updated: "=updated", }, })); 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"], (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. page.document?.getElementsByClassName("hljs-comment").forEach( (codeCommentElement) => { const docStringRegex = /^\/\*\*.*\*\/$/gsm; const matchResult = codeCommentElement.innerText.match(docStringRegex); if (matchResult) { codeCommentElement.classList.add("docstring"); } }, ); }); }); export default site;