-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.eleventy.js
More file actions
62 lines (55 loc) · 2.11 KB
/
.eleventy.js
File metadata and controls
62 lines (55 loc) · 2.11 KB
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
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("src/scripts");
eleventyConfig.addWatchTarget("src/styles/");
eleventyConfig.addWatchTarget("src/scripts/");
eleventyConfig.addFilter("limit", function(array, limit) {
return array.slice(0, limit);
});
// Date formatting filter for articles
eleventyConfig.addFilter("date", function(dateString, format) {
if (!dateString) return "";
const date = new Date(dateString);
const months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
// Support "MMMM d, yyyy" format
if (format === "MMMM d, yyyy") {
return `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
}
// Default ISO format
return date.toISOString().split('T')[0];
});
// Extract plain text from first block for excerpt
eleventyConfig.addFilter("extractExcerpt", function(body, maxLength = 150) {
if (!body || !Array.isArray(body)) return "";
for (const block of body) {
if (block._type === 'block' && block.children) {
const text = block.children.map(span => span.text || '').join('');
if (text) {
return text.length > maxLength ? text.substring(0, maxLength) + '...' : text;
}
}
}
return "";
});
eleventyConfig.addFilter("filterByStatus", function(array, status) {
return array.filter(item => item.status === status);
});
eleventyConfig.addCollection("designStyles", function(collectionApi) {
return collectionApi.getAll().filter(item => item.data.designStyle);
});
return {
dir: {
input: "src",
output: "public",
includes: "_includes",
data: "_data"
},
// Use DEPLOY_PATH_PREFIX for GitHub Pages deployment only
// This avoids pathPrefix issues during CI testing where GITHUB_ACTIONS is auto-set
pathPrefix: process.env.DEPLOY_PATH_PREFIX || "/",
templateFormats: ["njk", "md", "html"],
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk"
};
};