-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
98 lines (84 loc) · 2.63 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
92
93
94
95
96
97
98
//const navigationPlugin = require('@11ty/eleventy-navigation');
const yaml = require("js-yaml");
const pluginImages = require("./.eleventy.images.js");
const pluginShortcodes = require("./.eleventy.shortcodes.js");
const pluginFilters= require("./.eleventy.filters.js");
const tableOfContent = require("@uncenter/eleventy-plugin-toc");
module.exports = function(config) {
config.addDataExtension("yaml", contents => yaml.load(contents));
config.addGlobalData("env", process.env.ELEVENTY_ENV);
//////////// Collections
const isNotDraft = item =>
process.env.ELEVENTY_ENV !== 'production' || !item.data.draft;
config.addCollection('caseStudyProjects', (collection) => {
return collection.getFilteredByGlob('src/pages/projects/**/*.md')
.filter((item) =>
item.data.type === "case-study" &&
item.data.enabled
)
.filter(isNotDraft)
.sort((a, b) => a.data.order - b.data.order);
});
config.addCollection('petProjects', (collection) => {
return collection.getFilteredByGlob('src/pages/projects/**/*.md')
.filter((item) =>
item.data.type === "pet" &&
item.data.enabled
)
.filter(isNotDraft)
.sort((a, b) => a.data.order - b.data.order);
});
config.addCollection('allProjects', (collection) => {
const caseStudyProjects = collection.getFilteredByGlob('src/pages/projects/**/*.md')
.filter((item) =>
item.data.type === "case-study" &&
item.data.enabled
)
.filter(isNotDraft)
.sort((a, b) => a.data.order - b.data.order);
const petProjects = collection.getFilteredByGlob('src/pages/projects/**/*.md')
.filter((item) =>
item.data.type === "pet" &&
item.data.enabled
)
.filter(isNotDraft)
.sort((a, b) => a.data.order - b.data.order);
return [...caseStudyProjects, ...petProjects];
});
/////////// Plugins
config.addPlugin(tableOfContent, {
tags: ["h2"],
ul: true, // whether to a use a `ul` or `ol`
wrapper: function (toc) {
// wrapper around the generated TOC
return `${toc}`;
}
});
/////////// Custom plugins or settings
config.addPlugin(pluginShortcodes);
config.addPlugin(pluginImages);
config.addPlugin(pluginFilters);
/////////// Build options
config.addPassthroughCopy("src/fonts");
config.addPassthroughCopy( "src/assets/**/*");
config.addPassthroughCopy("src/*.txt");
config.addWatchTarget("./src/styles/**/*");
config.addWatchTarget("./src/pages/**/*");
return {
dir: {
input: "src",
output: "dist",
includes: "_includes",
layouts: "_templates",
data: "_data",
},
dataTemplateEngine: "njk",
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
passthroughFileCopy: true,
templateFormats: [
"md",
"njk",
],
};
};