-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
59 lines (47 loc) · 1.67 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
const sass = require('sass');
const path = require('node:path');
const fs = require('fs');
const tablesortPath = require.resolve('tablesort');
const tablesortNumberPath = require.resolve(
'tablesort/dist/sorts/tablesort.number.min.js'
);
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('src/robots.txt');
eleventyConfig.addPassthroughCopy('src/js/*');
eleventyConfig.addPassthroughCopy('src/fonts/*');
eleventyConfig.addPassthroughCopy('src/favicon/*');
eleventyConfig.addPassthroughCopy({
[tablesortPath]: 'js/tablesort.min.js',
[tablesortNumberPath]: 'js/tablesort.number.min.js',
});
eleventyConfig.addPassthroughCopy('src/background.svg');
eleventyConfig.addTemplateFormats('scss');
eleventyConfig.addExtension('scss', {
outputFileExtension: 'css',
compile: async function (inputContent, inputPath) {
let parsed = path.parse(inputPath);
let result = sass.compileString(inputContent, {
loadPaths: [parsed.dir || '.', this.config.dir.includes],
});
return async (data) => result.css;
},
compileOptions: {
permalink: function (contents, inputPath) {
let parsed = path.parse(inputPath);
if (parsed.name.startsWith('_')) {
return false;
}
return `${parsed.name}.css`;
},
},
});
eleventyConfig.addFilter('nan', (n) => (isNaN(n) || n === '' ? '' : n));
eleventyConfig.addFilter('rating', (n) => (n === undefined ? '?' : n));
return {
dir: { input: 'src', output: '_site' },
templateFormats: ['md', 'njk', 'html'],
markdownTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
dataTemplateEngine: 'njk',
};
};