2018-01-16 22:08:47 -05:00
|
|
|
const { DateTime } = require("luxon");
|
2018-01-23 01:26:36 -05:00
|
|
|
const liquidjsSyntaxHighlighter = require("./_src/eleventy-liquidjs-tag-highlight-prismjs");
|
2018-01-16 22:08:47 -05:00
|
|
|
|
2018-01-22 09:17:48 -05:00
|
|
|
function dateToISO(dateObj) {
|
|
|
|
return DateTime.fromJSDate(dateObj).toISO({ includeOffset: true, suppressMilliseconds: true });
|
2018-01-16 22:08:47 -05:00
|
|
|
}
|
|
|
|
|
2018-01-22 09:17:48 -05:00
|
|
|
module.exports = function(eleventyConfig) {
|
|
|
|
eleventyConfig.addLayoutAlias("post", "layouts/post.njk");
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("rssLastUpdatedDate", collection => {
|
|
|
|
if( !collection.length ) {
|
|
|
|
throw new Error( "Collection is empty in lastUpdatedDate filter." );
|
|
|
|
}
|
|
|
|
// Newest date in the collection
|
|
|
|
return dateToISO(collection[ collection.length - 1 ].date);
|
|
|
|
});
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("rssDate", dateObj => {
|
|
|
|
return dateToISO(dateObj);
|
|
|
|
});
|
|
|
|
|
|
|
|
eleventyConfig.addFilter("readableDate", dateObj => {
|
|
|
|
return DateTime.fromJSDate(dateObj).toFormat("dd LLL yyyy");
|
|
|
|
});
|
|
|
|
|
|
|
|
// compatibility with existing {% highlight js %} and others
|
|
|
|
eleventyConfig.addLiquidTag("highlight", liquidjsSyntaxHighlighter);
|
|
|
|
|
|
|
|
// only content in the `posts/` directory
|
|
|
|
eleventyConfig.addCollection("posts", function(collection) {
|
|
|
|
return collection.getAllSorted().filter(function(item) {
|
|
|
|
return item.inputPath.match(/^\.\/posts\//) !== null;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
templateFormats: [
|
2018-01-16 22:08:47 -05:00
|
|
|
"md",
|
|
|
|
"njk",
|
|
|
|
"html",
|
|
|
|
"png",
|
2018-01-22 09:17:48 -05:00
|
|
|
"jpg",
|
2018-01-16 22:08:47 -05:00
|
|
|
"css"
|
|
|
|
],
|
2018-01-22 09:17:48 -05:00
|
|
|
|
|
|
|
// if your site lives in a subdirectory, change this
|
2018-01-23 01:17:57 -05:00
|
|
|
urlPrefix: "/eleventy-base-blog/",
|
2018-01-22 09:17:48 -05:00
|
|
|
|
|
|
|
markdownTemplateEngine: "liquid",
|
2018-01-16 22:08:47 -05:00
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
dataTemplateEngine: "njk",
|
|
|
|
passthroughFileCopy: true,
|
|
|
|
dir: {
|
|
|
|
input: ".",
|
|
|
|
includes: "_includes",
|
|
|
|
data: "_data",
|
|
|
|
output: "_site"
|
2018-01-22 09:17:48 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|