-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
47 lines (40 loc) · 1.23 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
const path = require('path');
function sortByName(a, b) {
return a.inputPath.localeCompare(b.inputPath);
}
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy('src/_assets/normalize.css');
eleventyConfig.addPassthroughCopy('src/_assets/styles.css');
eleventyConfig.addPassthroughCopy('src/_assets/images/');
// Collection "uebungen"
eleventyConfig.addCollection('uebungen', function (collectionApi) {
return collectionApi
.getFilteredByGlob('src/uebungen/*.md')
.sort(sortByName);
});
// Collection "tests"
eleventyConfig.addCollection('tests', function (collectionApi) {
return collectionApi
.getFilteredByGlob('src/tests/*.md')
.sort(sortByName)
.map((item) => {
item.data.isTest = true;
return item;
});
});
// Ensure relative paths
eleventyConfig.addFilter('relativeUrl', (url, page) => {
if (!url.startsWith('/')) {
throw new Error('URL is already relative');
}
const relativeUrl = path.relative(page.filePathStem, url);
if (page.filePathStem === '/index') {
return path.relative('..', relativeUrl);
} else {
return relativeUrl;
}
});
return {
markdownTemplateEngine: 'njk',
};
};