2022-06-26 23:33:29 +00:00
|
|
|
const { DateTime } = require("luxon");
|
|
|
|
|
|
|
|
const pluginNavigation = require("@11ty/eleventy-navigation");
|
|
|
|
|
|
|
|
module.exports = function(eleventyConfig) {
|
|
|
|
eleventyConfig.addPlugin(pluginNavigation);
|
|
|
|
|
2022-06-26 23:58:49 +00:00
|
|
|
eleventyConfig.addPassthroughCopy("css");
|
2022-07-24 10:45:01 +00:00
|
|
|
eleventyConfig.addPassthroughCopy("dl");
|
2022-06-30 20:37:32 +00:00
|
|
|
eleventyConfig.addPassthroughCopy("images");
|
2022-06-26 23:58:49 +00:00
|
|
|
|
2022-06-26 23:33:29 +00:00
|
|
|
eleventyConfig.addFilter("readableDate", dateObj => {
|
|
|
|
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).setLocale("fr").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');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Get the first `n` elements of a collection.
|
|
|
|
eleventyConfig.addFilter("head", (array, n) => {
|
|
|
|
if (!Array.isArray(array) || array.length === 0) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
if (n < 0) {
|
|
|
|
return array.slice(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
return array.slice(0, n);
|
|
|
|
});
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("nlToBr", string => string.replaceAll('\n', '<br>'))
|
2022-06-28 12:45:08 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
// Pre-process *.md files with: (default: `liquid`)
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
|
|
|
|
// Pre-process *.html files with: (default: `liquid`)
|
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
}
|
2022-06-26 23:33:29 +00:00
|
|
|
}
|
|
|
|
|