-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
41 lines (35 loc) · 1.03 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var site = require('./src/_data/site');
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('src/assets/fonts');
eleventyConfig.addPassthroughCopy('src/assets/img');
eleventyConfig.addPassthroughCopy('src/favicon.ico');
eleventyConfig.addPassthroughCopy('src/robots.txt');
// Filters
eleventyConfig.addFilter('dateToISO', (dateObj) => {
let _date = new Date(dateObj);
return _date.toISOString().split('T')[0];
});
// Shortcodes
const UUID = Math.random().toString(36).slice(-8);
eleventyConfig.addShortcode('VERSION', function (value) {
return `${UUID}`;
});
function removeTrailingSlash(str) {
return str.replace(/\/+$/, '');
}
const BASE_URL = removeTrailingSlash(process.env.BASE_URL || site.BASE_URL);
eleventyConfig.addShortcode('BASE_URL', function (value) {
return BASE_URL;
});
return {
dir: {
data: '_data',
input: 'src',
output: '_site'
},
templateFormats: ['html', 'njk'],
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dataTemplateEngine: "njk"
}
}