-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheleventy.config.js
150 lines (129 loc) · 3.75 KB
/
eleventy.config.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
const path = require('path');
const Image = require('@11ty/eleventy-img');
const markdownIt = require("markdown-it");
module.exports = (config) => {
/*
Setup collections
https://www.11ty.dev/docs/collections/
*/
config.addCollection("posts", function(collectionApi) {
return collectionApi.getFilteredByGlob("src/_content/posts/*.md");
});
config.addCollection("places", function(collectionApi) {
return collectionApi.getFilteredByGlob("src/_content/places/*.md");
});
config.addCollection("presenters", function(collectionApi) {
return collectionApi.getFilteredByGlob("src/_content/presenters/*.md");
});
config.addCollection("organizers", function(collectionApi) {
return collectionApi.getFilteredByGlob("src/_content/organizers/*.md").filter(item => !item.data.hidden);
});
config.addCollection("sponsorsByLevel", function(collectionApi) {
const sponsors = collectionApi.getFilteredByGlob("src/_content/sponsors/*.md");
const visibleSponsors = sponsors.filter(sponsor => !sponsor.data.hidden);
const levelOrder = [
"Diamond",
"Platnum",
"Gold",
"Silver",
"Bronze",
"Coffee",
"Opportunity Grant",
"Community",
];
const sponsorsByLevel = visibleSponsors.reduce((acc, sponsor) => {
const level = sponsor.data.level;
if (!acc[level]) {
acc[level] = [];
}
acc[level].push(sponsor);
return acc;
}, {});
// Sort levels based on predefined order
const sortedSponsorsByLevel = {};
levelOrder.forEach(level => {
if (sponsorsByLevel[level]) {
sortedSponsorsByLevel[level] = sponsorsByLevel[level];
}
});
return sortedSponsorsByLevel;
});
/*
Setup passthrough file copy
https://www.11ty.dev/docs/copy/
*/
config.addPassthroughCopy("src/assets/img/**/*");
config.addPassthroughCopy("src/assets/js/");
config.addPassthroughCopy("src/assets/favicons/");
config.addPassthroughCopy({
"src/_content/sponsors/*.{png,jpg,jpeg,svg}": "sponsors/",
"src/_content/places/*.{png,jpg,jpeg,webp}": "venue/",
});
config.addPassthroughCopy("CNAME");
/*
Setup watch targets
https://www.11ty.dev/docs/watch-serve/#add-your-own-watch-targets
*/
config.addWatchTarget("src/assets/js/");
/*
Shortcodes
*/
config.addLiquidShortcode("year", () => `${new Date().getFullYear()}`);
// TODO: Accept widths or support different widths
config.addLiquidShortcode("image", async function(
src,
outputDir,
urlPath,
alt,
sizes,
classes = "") {
let metadata = await Image(src, {
widths: [300, 600],
formats: ["webp"],
outputDir,
urlPath,
filenameFormat: function (id, src, width, format, options) {
// Get the original filename without the extension
const originalFilename = path.basename(src, path.extname(src));
return `${originalFilename}-${width}.${format}`;
},
});
let imageAttributes = {
class: classes,
alt,
sizes,
loading: "lazy",
decoding: "async",
};
return Image.generateHTML(metadata, imageAttributes);
});
/*
Filters
*/
config.addFilter("markdown", function(content = "") {
let markdown = markdownIt({
html: true,
breaks: true,
linkify: true
});
return markdown.render(content);
});
/*
Misc configuration
*/
config.setFrontMatterParsingOptions({
excerpt: true,
excerpt_separator: "<!-- excerpt -->"
});
return {
dir: {
input: "src",
output: "dist",
layouts: '_layouts',
},
// Use Liquid for templating
// https://www.11ty.dev/docs/languages/liquid/
htmlTemplateEngine: "liquid",
markdownTemplateEngine: "liquid"
}
};