-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
60 lines (50 loc) · 1.8 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
const copydir = require('copy-dir');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
const svgContents = require('eleventy-plugin-svg-contents');
const writeCSS = require('./_client/config/writeCSS');
const inlineContents = require('./_client/config/filter-inlineContents');
module.exports = function(eleventyConfig) {
// The Config object.
const dir = {
layouts: '_layouts',
data: '_client/data',
};
// Watch files.
eleventyConfig.addWatchTarget('./_client/src/scss/');
// Process files before building.
eleventyConfig.on('beforeBuild', writeCSS);
// Manually copy CSS directory to ensure it arrives.
eleventyConfig.on('afterBuild', () => {
console.log('Copying _client/src/css to _site/assets/css');
copydir('./_client/src/css', './_site/assets/css', { cover: true });
});
// Plugins.
eleventyConfig.addPlugin(syntaxHighlight, {
lineSeparator: '<br>\n',
});
eleventyConfig.addPlugin(svgContents);
// Copy the directories.
eleventyConfig.addPassthroughCopy({
'_client/src/images/**/*.ico': '.',
'_client/src/images': 'assets/images',
'_client/src/fonts': 'assets/fonts',
});
// Don't use the gitignore file.
eleventyConfig.setUseGitIgnore(false);
// Filters.
eleventyConfig.addFilter('inlineContents', inlineContents);
eleventyConfig.addFilter('toUTCString', function(date) {
return new Date(date).toUTCString();
});
// Override BrowserSync options.
eleventyConfig.setBrowserSyncConfig({
server: false,
proxy: 'https://goodguyry.dev',
});
// Simple posts collection in descending order.
// Using Liquid's `reverse` filter had strange side-effects.
eleventyConfig.addCollection('descendingPosts', (collectionApi) => {
return collectionApi.getFilteredByTag('post').reverse();
});
return { dir };
};