-
-
Notifications
You must be signed in to change notification settings - Fork 493
/
defaultConfig.js
120 lines (109 loc) · 3.07 KB
/
defaultConfig.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const urlFilter = require("./Filters/Url");
const serverlessUrlFilter = require("./Filters/ServerlessUrl");
const slugFilter = require("./Filters/Slug");
const slugifyFilter = require("./Filters/Slugify");
const getLocaleCollectionItem = require("./Filters/GetLocaleCollectionItem");
const getCollectionItemIndex = require("./Filters/GetCollectionItemIndex");
module.exports = function (config) {
let templateConfig = this;
config.addFilter("slug", slugFilter);
config.addFilter("slugify", slugifyFilter);
// Add pathPrefix manually to a URL
config.addFilter("url", function addPathPrefix(url, pathPrefixOverride) {
let pathPrefix = pathPrefixOverride || templateConfig.getPathPrefix();
return urlFilter.call(this, url, pathPrefix);
});
config.addFilter("log", (input, ...messages) => {
console.log(input, ...messages);
return input;
});
config.addFilter("serverlessUrl", serverlessUrlFilter);
config.addFilter(
"getCollectionItemIndex",
function (collection, pageOverride) {
return getCollectionItemIndex.call(this, collection, pageOverride);
}
);
config.addFilter(
"getCollectionItem",
function (collection, pageOverride, langCode) {
return getLocaleCollectionItem.call(
this,
config,
collection,
pageOverride,
langCode,
0
);
}
);
config.addFilter(
"getPreviousCollectionItem",
function (collection, pageOverride, langCode) {
return getLocaleCollectionItem.call(
this,
config,
collection,
pageOverride,
langCode,
-1
);
}
);
config.addFilter(
"getNextCollectionItem",
function (collection, pageOverride, langCode) {
return getLocaleCollectionItem.call(
this,
config,
collection,
pageOverride,
langCode,
1
);
}
);
return {
templateFormats: [
"liquid",
"ejs",
"md",
"hbs",
"mustache",
"haml",
"pug",
"njk",
"html",
"11ty.js",
],
// if your site lives in a subdirectory, change this
pathPrefix: "/",
markdownTemplateEngine: "liquid",
htmlTemplateEngine: "liquid",
dataTemplateEngine: false, // change in 1.0
htmlOutputSuffix: "-o",
// Renamed from `jsDataFileSuffix` in 2.0 (and swapped to an Array)
// If you remove "" we won’t look for dir/dir.json or file.json
dataFileSuffixes: [".11tydata", ""],
// "index" will look for `directory/index.*` directory data files instead of `directory/directory.*`
dataFileDirBaseNameOverride: false,
keys: {
package: "pkg",
layout: "layout",
permalink: "permalink",
permalinkRoot: "permalinkBypassOutputDir",
engineOverride: "templateEngineOverride",
computed: "eleventyComputed",
},
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site",
},
// deprecated, use config.addHandlebarsHelper
handlebarsHelpers: {},
// deprecated, use config.addNunjucksFilter
nunjucksFilters: {},
};
};