-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.eleventy.js
125 lines (105 loc) · 3.95 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
module.exports = function(eleventyConfig) {
// File extensions to passthrough copy
eleventyConfig.setTemplateFormats([
"pug",
"md",
"png",
"jpg",
"svg",
"ico",
"mp4",
"gif",
"pdf",
"webmanifest",
"xml",
"txt",
"woff2"
]);
eleventyConfig.addPassthroughCopy("src/scripts");
eleventyConfig.addPassthroughCopy("src/CNAME");
// TODO: switch to the new 11ty server: https://www.11ty.dev/docs/dev-server/
eleventyConfig.addWatchTarget("**.pug");
eleventyConfig.addWatchTarget("src/**");
eleventyConfig.addWatchTarget("src/_includes/**");
eleventyConfig.addWatchTarget("src/styles.css");
eleventyConfig.setWatchThrottleWaitTime(100);
// Custom markdown processor
let markdownIt = require("markdown-it");
let options = {
html: true,
linkify: true,
typographer: true,
breaks: true
};
let markdownLib = markdownIt(options);
eleventyConfig.setLibrary("md", markdownLib);
// Pug specific options
eleventyConfig.setPugOptions({
debug: false,
pretty: " "
});
// Template aliases
eleventyConfig.addLayoutAlias('base', 'layouts/base.pug');
eleventyConfig.addLayoutAlias('post', 'layouts/post.pug');
eleventyConfig.addLayoutAlias('project', 'layouts/project.pug');
// TODO: currently hiding the BREAK microsite
eleventyConfig.ignores.add("src/break");
// eleventyConfig.addPassthroughCopy("src/break/styles.css");
// Sort all pages for sitemap
eleventyConfig.addCollection("sitemap", function(collectionApi) {
return collectionApi.getAll().sort((a, b) => {
if (a.url < b.url) {
return -1;
} else if (a.url > b.url) {
return 1;
} else {
return 0;
}
});
});
// Reverse sort posts, only show this and last year's posts
eleventyConfig.addCollection("recentPosts", function(collectionApi) {
return collectionApi.getFilteredByTag("post").reverse().filter(post => {
const lastYear = (new Date()).getFullYear() - 1;
return post.data.date.getFullYear() >= lastYear;
});
});
// Reverse sort posts
eleventyConfig.addCollection("post", function(collectionApi) {
return collectionApi.getFilteredByTag("post").reverse();
});
// Reverse sort featured posts
eleventyConfig.addCollection("featured", function(collectionApi) {
return collectionApi.getFilteredByTag("featured").reverse();
});
// Omit archived projects, sort remaining in reverse order
eleventyConfig.addCollection("project", function(collectionApi) {
return collectionApi.getFilteredByTag("project").reverse().filter(post => {
return !post.data.tags.includes("archive");
});
});
// For "featured portfolio" projects, allow manual positioning
eleventyConfig.addCollection("portfolio", function(collectionApi) {
// TODO: will need some filtering here I think
return collectionApi.getFilteredByTag("portfolio").sort((a, b) => {
return a.data.position - b.data.position;
});
});
// TODO: media “tags”, basically want to create a collection per data.media value
/**
* tags for design projects:
* - portfolio - shown on homepage [done]
* - project - this is a design project [I think done]
* - archive - TODO: do not show this project except by permalink?
*/
// TODO: Include speedlify score somewhere, maybe on the design system page
// https://github.com/zachleat/speedlify-score
//
/* TODO: available hack for using pug filters
see https://github.com/11ty/eleventy/issues/1523
global.filters = eleventyConfig.javascriptFunctions; // magic happens here
eleventyConfig.setPugOptions({ // and here
globals: ['filters']
});
*/
};