Documentation for my projects & stuff, build using 11ty.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 94 lines 2.6 kB view raw
1import path from "node:path"; 2 3import * as sass from "sass"; 4import htmlmin from "html-minifier-terser"; 5 6import markdownIt from "markdown-it"; 7import markdownItAnchor from "markdown-it-anchor"; 8 9import { IdAttributePlugin } from "@11ty/eleventy"; 10 11import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight"; 12import eleventyNavigationPlugin from "@11ty/eleventy-navigation"; 13import tableOfContents from "eleventy-plugin-toc"; 14 15export default async function (eleventyConfig) { 16 eleventyConfig.setInputDirectory("src"); 17 18 eleventyConfig.addPassthroughCopy({ 19 "src/public": "/", 20 }); 21 22 const md = markdownIt({ 23 html: true, 24 linkify: true, 25 typographer: true, 26 }).use(markdownItAnchor); 27 28 const defaultTableOpen = 29 md.renderer.rules.table_open || 30 ((tokens, idx, options, env, self) => 31 self.renderToken(tokens, idx, options)); 32 33 const defaultTableClose = 34 md.renderer.rules.table_close || 35 ((tokens, idx, options, env, self) => 36 self.renderToken(tokens, idx, options)); 37 38 md.renderer.rules.table_open = (tokens, idx, options, env, self) => 39 '<div class="tableWrapper">\n' + 40 defaultTableOpen(tokens, idx, options, env, self); 41 42 md.renderer.rules.table_close = (tokens, idx, options, env, self) => 43 defaultTableClose(tokens, idx, options, env, self) + "</div>\n"; 44 45 eleventyConfig.setLibrary("md", md); 46 47 // Extensions 48 eleventyConfig.addExtension("scss", { 49 outputFileExtension: "css", 50 51 // opt-out of Eleventy Layouts 52 useLayouts: false, 53 54 compile: async function (inputContent, inputPath) { 55 let parsed = path.parse(inputPath); 56 if (parsed.name.startsWith("_")) { 57 return; 58 } 59 60 let result = sass.compileString(inputContent, { 61 loadPaths: [parsed.dir || ".", this.config.dir.includes], 62 style: "compressed", 63 }); 64 this.addDependencies(inputPath, result.loadedUrls); 65 66 return async (data) => { 67 return result.css; 68 }; 69 }, 70 }); 71 72 // File formats 73 eleventyConfig.addTemplateFormats("scss"); 74 75 // Transforms 76 eleventyConfig.addTransform("htmlmin", function (content) { 77 if ((this.page.outputPath || "").endsWith(".html")) { 78 let minified = htmlmin.minify(content, { 79 removeComments: true, 80 collapseWhitespace: true, 81 }); 82 83 return minified; 84 } 85 86 return content; 87 }); 88 89 // Plugins 90 eleventyConfig.addPlugin(IdAttributePlugin); 91 eleventyConfig.addPlugin(syntaxHighlight); 92 eleventyConfig.addPlugin(eleventyNavigationPlugin); 93 eleventyConfig.addPlugin(tableOfContents); 94}