-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
91 lines (70 loc) · 2.42 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const { DateTime } = require('luxon');
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const pluginSass = require('eleventy-plugin-dart-sass');
const pluginRss = require("@11ty/eleventy-plugin-rss");
const path = require('path');
module.exports = function(eleventyConfig) {
eleventyConfig.addLayoutAlias('post', 'layouts/post.njk');
eleventyConfig.addLayoutAlias('page', 'layouts/page.njk');
eleventyConfig.addCollection('tagList', require('./_11ty/getTagList'));
eleventyConfig.addPassthroughCopy('src/assets');
// eleventyConfig.addPassthroughCopy('src/css');
// Filters
eleventyConfig.addFilter('readableDate', dateObj => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat(
'dd LLL yyyy'
);
});
eleventyConfig.addFilter('ymd', dateObj => { // yearmonthdate
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat(
'yyyy/MM/dd'
);
});
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
eleventyConfig.addFilter('htmlDateString', dateObj => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
});
eleventyConfig.addFilter('year', function(dateObj) {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy');
});
// Get the first `n` elements of a collection.
eleventyConfig.addFilter('head', (array, n) => {
if (n < 0) {
return array.slice(n);
}
return array.slice(0, n);
});
eleventyConfig.addFilter('console', function(value) {
const output = JSON.stringify(value);
return output;
});
// Plugins
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPlugin(syntaxHighlight, {
// only install the markdown highlighter
templateFormats: ["md"],
init: function({ Prism }) {
// Add your own custom language to Prism!
}
});
eleventyConfig.addPlugin(pluginSass, {
includePaths: ['./src/**/*.{scss,sass}'],
sassLocation: path.join(__dirname, 'src/'),
sassIndexFile: 'styles.scss',
outDir: path.join(__dirname, 'dist/'),
outPath: './',
outFileName: 'styles.css',
// Enable sourcemaps for ez debugging
sourcemaps: true
});
// You can return your Config object (optional).
return {
templateFormats: ['md', 'njk', 'html', 'liquid'],
htmlTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
dir: {
input: 'src',
output: 'dist'
}
};
};