sofi-web/.eleventy.js
2023-12-06 18:17:16 +01:00

39 lines
No EOL
1.2 KiB
JavaScript

const { DateTime } = require("luxon")
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
const timeToRead = require("eleventy-plugin-time-to-read")
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy({ "static": "/" })
eleventyConfig.addPlugin(timeToRead, {
language: "en",
style: "long",
hours: "auto",
minutes: true,
})
eleventyConfig.setLibrary("md", markdownIt({
html: true
}).use(markdownItAnchor, {
level: 2
}))
eleventyConfig.addFilter("relevantTags", tags => tags.filter(v => !["archived", "post"].includes(v)))
eleventyConfig.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).setLocale("es-ES").toFormat("dd LLL yyyy");
})
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
eleventyConfig.addFilter('htmlDateString', dateObj => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
})
return {
passthroughFileCopy: true,
dir: {
input: "src"
}
}
}