Created
October 5, 2023 13:24
-
-
Save shawnthompson/a48db89afbf6c17c87b854065f1df980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const markdownIt = require('markdown-it'); | |
const markdownItAnchor = require('markdown-it-anchor'); | |
const markdownItAttrs = require('markdown-it-attrs'); | |
const { EleventyHtmlBasePlugin } = require('@11ty/eleventy'); | |
const stripHtml = require('string-strip-html'); | |
// const { slugify } = require("@11ty/eleventy"); | |
module.exports = function(eleventyConfig) { | |
const slugifyFilter = eleventyConfig.javascriptFunctions.slugify; | |
eleventyConfig.addFilter("stripTagsSlugify", (str) => { | |
if (!str) return; | |
return slugifyFilter(stripHtml(str), { | |
lower: true, | |
strict: true, | |
customReplacements: [["accessibility", "a11y"]], | |
}); | |
}); | |
// eleventyConfig.addPlugin("slugify", (str) => { | |
// if (!str) { | |
// return; | |
// } | |
// return slugify(str, { | |
// // customReplacements: [["<[^>]*>", ""]], | |
// customReplacements: [["accessibility", "a11y"]], | |
// }); | |
// }); | |
const { DateTime } = require("luxon"); | |
let markdownItOptions = { | |
html: true // you can include HTML tags | |
} | |
eleventyConfig.addPlugin(EleventyHtmlBasePlugin); | |
eleventyConfig.addFilter("localeMatch", function (collection) { | |
const { locale } = this.ctx; // avoid retrieving it for each item | |
return collection.filter((item) => item.data.locale === locale); | |
}); | |
eleventyConfig.setLibrary("md", markdownIt(markdownItOptions).use(markdownItAnchor).use(markdownItAttrs)) | |
eleventyConfig.addFilter("postDate", (dateObj) => { | |
return DateTime.fromJSDate(dateObj, { zone: "utc" }) | |
.setLocale("en") | |
.toFormat("yyyy'-'MM'-'dd"); | |
}); | |
eleventyConfig.addPassthroughCopy({ "./src/_docs" : "docs" }); | |
eleventyConfig.addPassthroughCopy({ "./src/_images" : "img" }); | |
eleventyConfig.addPassthroughCopy({ "./src/CNAME" : "CNAME" }); | |
return { | |
dir: { | |
input : "src", | |
output : "_site", | |
includes : "_includes", | |
data : "_data" | |
}, | |
templateFormats : ["html", "md", "njk", "css"], | |
htmlTemplateEngine : "njk", | |
markdownTemplate : "njk", | |
setUseGitIgnore : false | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment