xmitter-11ty/.eleventy.js
Zach Leatherman 963b5d46e6 Refactors Liquid syntax highlighters to add line highlights.
Usage (ranges are space separated):

{% highlight js 1,4-6 %}
One range
Adds `highlight-line-active` to lines 1,4,5,6

{% highlight js 3-4 -1 %}
Two ranges (add/remove), remove is N/A
Adds `highlight-line-add` to lines 3,4

{% highlight js -1 3-4 %}
Two ranges (add/remove), add is N/A
Adds `highlight-line-remove` to lines 3,4

{% highlight js 3-4 5,8-10 %}
Two ranges, both are used
Adds `highlight-line-add` to lines 3-4
Adds `highlight-line-remove` to lines 5,8,9,10
2018-01-26 22:12:46 -06:00

65 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { DateTime } = require("luxon");
const highlighters = require("./_src/eleventy-liquidjs-tag-highlight");
function dateToISO(dateObj) {
return DateTime.fromJSDate(dateObj).toISO({ includeOffset: true, suppressMilliseconds: true });
}
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", highlighters.prismjs);
// 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: [
"md",
"njk",
"html",
"png",
"jpg",
"css"
],
// If your site lives in a different subdirectory, change this.
// Leading or trailing slashes are all normalized away, so dont worry about it.
// If you dont have a subdirectory, use "" or "/" (they do the same thing)
// This is only used for URLs (it does not affect your file structure)
pathPrefix: "/",
markdownTemplateEngine: "liquid",
htmlTemplateEngine: "njk",
dataTemplateEngine: "njk",
passthroughFileCopy: true,
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site"
}
};
};