import lume from "lume/mod.ts"; import jsx from "lume/plugins/jsx.ts"; import katex from "lume/plugins/katex.ts"; import mdx from "lume/plugins/mdx.ts"; import prism from "lume/plugins/prism.ts"; import slugify_urls from "lume/plugins/slugify_urls.ts"; import tailwindcss from "lume/plugins/tailwindcss.ts"; import postcss from "lume/plugins/postcss.ts"; import metas from "lume/plugins/metas.ts"; import { RenderRule } from "npm:@types/markdown-it/lib/renderer.d.ts"; import MarkdownIt from "npm:@types/markdown-it"; import esbuild from "lume/plugins/esbuild.ts"; import sourceMaps from "lume/plugins/source_maps.ts"; const site = lume({ src: "./src", dest: "./_site", location: new URL("https://eddie.sh"), }); site.use(katex()); site.use(jsx()); site.use(mdx()); site.use(prism()); site.use(slugify_urls()); site.use(tailwindcss()); site.use(postcss()); site.use(metas()); site.use(esbuild()); site.use(sourceMaps()); let original_link_open_renderer: RenderRule; site.hooks.markdownIt((md: MarkdownIt) => { const proxy: RenderRule = (tokens, idx, options, _, self) => self.renderToken(tokens, idx, options); original_link_open_renderer = md.renderer.rules.link_open || proxy; }); const link_open_rule_add_noopener_noreferrer: RenderRule = (tokens, idx, options, env, self) => { for (const token of tokens) { if (token.type === "link_open") { token.attrJoin("rel", "noopener"); token.attrJoin("rel", "noreferrer"); } } return original_link_open_renderer(tokens, idx, options, env, self); }; site.hooks.addMarkdownItRule("link_open", link_open_rule_add_noopener_noreferrer); export default site;