2022-05-31 18:36:19 +00:00
|
|
|
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
|
2023-01-20 15:34:12 +00:00
|
|
|
const pluginRss = require('@11ty/eleventy-plugin-rss')
|
2022-05-31 18:36:19 +00:00
|
|
|
|
2022-05-31 13:09:45 +00:00
|
|
|
module.exports = function (eleventyConfig) {
|
|
|
|
const parseDate = (str) => {
|
|
|
|
if (str instanceof Date) {
|
|
|
|
return str;
|
|
|
|
}
|
2022-05-31 14:10:07 +00:00
|
|
|
return Date.parse(str);
|
2022-05-31 13:09:45 +00:00
|
|
|
};
|
|
|
|
|
2022-05-31 14:10:07 +00:00
|
|
|
const formatPart = (part, date) =>
|
2022-05-31 18:36:19 +00:00
|
|
|
new Intl.DateTimeFormat("en", part).format(date);
|
|
|
|
|
2023-01-20 15:34:12 +00:00
|
|
|
eleventyConfig.addPlugin(pluginRss)
|
2022-05-31 18:36:19 +00:00
|
|
|
eleventyConfig.addPlugin(syntaxHighlight)
|
2022-05-31 14:10:07 +00:00
|
|
|
|
2022-05-31 13:09:45 +00:00
|
|
|
eleventyConfig.addPassthroughCopy({ "src/static": "/" });
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("date_to_datetime", (obj) => {
|
|
|
|
const date = parseDate(obj);
|
2022-05-31 14:10:07 +00:00
|
|
|
return date.toISOString();
|
2022-05-31 13:09:45 +00:00
|
|
|
});
|
|
|
|
|
2022-05-31 14:10:07 +00:00
|
|
|
eleventyConfig.addFilter("date_formatted", (obj) => {
|
|
|
|
const date = parseDate(obj);
|
|
|
|
|
|
|
|
const month = formatPart({ month: "short" }, date);
|
|
|
|
const day = formatPart({ day: "numeric" }, date);
|
|
|
|
const year = formatPart({ year: "numeric" }, date);
|
|
|
|
|
|
|
|
return `${month} ${day}, ${year}`;
|
|
|
|
});
|
|
|
|
|
|
|
|
eleventyConfig.addCollection('posts', collection => {
|
|
|
|
return collection.getFilteredByGlob('src/posts/*.md').reverse()
|
|
|
|
})
|
|
|
|
|
2022-05-31 13:09:45 +00:00
|
|
|
return {
|
|
|
|
templateFormats: ["njk", "md", "html"],
|
|
|
|
dir: {
|
|
|
|
input: "src",
|
|
|
|
includes: "_includes",
|
|
|
|
data: "_data",
|
|
|
|
output: "www",
|
|
|
|
},
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
dataTemplateEngine: "njk",
|
|
|
|
passthroughFileCopy: false,
|
|
|
|
};
|
|
|
|
};
|