forked from samuel-p/sp-codes.de
85 lines
2.7 KiB
JavaScript
85 lines
2.7 KiB
JavaScript
const pluginRev = require("eleventy-plugin-rev");
|
|
const pluginSass = require("eleventy-sass");
|
|
const pluginTinyHtml = require("@sardine/eleventy-plugin-tinyhtml");
|
|
const pluginNavigation = require("@11ty/eleventy-navigation");
|
|
|
|
module.exports = function (eleventyConfig) {
|
|
eleventyConfig.addPlugin(pluginRev);
|
|
eleventyConfig.addPlugin(pluginTinyHtml);
|
|
eleventyConfig.addPlugin(pluginSass, {
|
|
sass: {
|
|
loadPaths: ["node_modules"],
|
|
style: "compressed",
|
|
sourceMap: false,
|
|
},
|
|
compileOptions: {
|
|
permalink: function (contents, inputPath) {
|
|
return (data) => {
|
|
return data.page.filePathStem.replace(/^\/scss\//, "/css/") + ".css";
|
|
};
|
|
}
|
|
},
|
|
rev: true
|
|
});
|
|
eleventyConfig.addPlugin(pluginNavigation);
|
|
|
|
eleventyConfig.setUseGitIgnore(false);
|
|
eleventyConfig.addPassthroughCopy({
|
|
"src/img": "img",
|
|
"src/font": "font",
|
|
"src/favicon.*": "",
|
|
});
|
|
eleventyConfig.addShortcode("translatedUrl", function (currentLocale, newLocale) {
|
|
return this.page.url.replace(new RegExp(`\/${currentLocale}\/`), `/${newLocale}/`);
|
|
});
|
|
|
|
eleventyConfig.addFilter('year', function (value) {
|
|
return value * 12;
|
|
});
|
|
|
|
eleventyConfig.addFilter("sum", function (value) {
|
|
return value.map(d => d.amount).reduce((a, b) => a + b, 0);
|
|
});
|
|
|
|
eleventyConfig.addFilter("amount", function (value) {
|
|
// TODO update language dynamically
|
|
return value.toLocaleString('de', {minimumFractionDigits: 2});
|
|
});
|
|
|
|
eleventyConfig.addFilter("banktransfers", function (donations) {
|
|
return donations
|
|
.flatMap(y => y.donations)
|
|
.filter(d => d.via === 'banktransfer')
|
|
.filter(d => d.first)
|
|
.length;
|
|
});
|
|
|
|
eleventyConfig.addFilter("cash", function (donations) {
|
|
return donations
|
|
.flatMap(y => y.donations)
|
|
.filter(d => d.via === 'cash')
|
|
.filter(d => d.first)
|
|
.length;
|
|
});
|
|
|
|
eleventyConfig.addFilter('getServiceById', (services, serviceId) => {
|
|
return services.find(s => s.id === serviceId);
|
|
});
|
|
|
|
return {
|
|
// Pre-process *.md files with: (default: `liquid`)
|
|
markdownTemplateEngine: "njk",
|
|
// Pre-process *.html files with: (default: `liquid`)
|
|
htmlTemplateEngine: "njk",
|
|
// Opt-out of pre-processing global data JSON files: (default: `liquid`)
|
|
dataTemplateEngine: false,
|
|
|
|
dir: {
|
|
input: "src",
|
|
includes: "_includes",
|
|
layouts: "_includes/layouts",
|
|
data: "_data",
|
|
output: "dist"
|
|
}
|
|
};
|
|
};
|