-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
53 lines (47 loc) · 1.56 KB
/
.eleventy.js
File metadata and controls
53 lines (47 loc) · 1.56 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
module.exports = function(eleventyConfig) {
// Copy static files
eleventyConfig.addPassthroughCopy("src/media");
eleventyConfig.addPassthroughCopy("src/css");
eleventyConfig.addPassthroughCopy("src/js");
eleventyConfig.addPassthroughCopy("src/.well-known");
eleventyConfig.addPassthroughCopy("src/CNAME");
// Add date filters
eleventyConfig.addFilter("dateReadable", (dateObj) => {
return new Date(dateObj).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
});
// RSS date filter
eleventyConfig.addFilter("dateToRfc3339", (dateObj) => {
return new Date(dateObj).toISOString();
});
// Get newest date in collection
eleventyConfig.addFilter("getNewestCollectionItemDate", (collection) => {
return new Date(Math.max(...collection.map(item => item.date)));
});
// Convert HTML to absolute URLs
eleventyConfig.addFilter("htmlToAbsoluteUrls", (htmlContent, base) => {
if (!htmlContent) return '';
// Simple implementation - in production you might want to use a proper HTML parser
return htmlContent.replace(/src="\/([^"]+)"/g, `src="${base}/$1`)
.replace(/href="\/([^"]+)"/g, `href="${base}/$1`);
});
// Add excerpt support
eleventyConfig.setFrontMatterParsingOptions({
excerpt: true,
excerpt_separator: "<!-- excerpt -->"
});
return {
dir: {
input: "src",
output: "_site",
includes: "_includes",
layouts: "_layouts",
data: "_data"
},
htmlTemplateEngine: "njk",
markdownTemplateEngine: "njk"
};
};