-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheleventy.config.js
More file actions
35 lines (26 loc) · 899 Bytes
/
eleventy.config.js
File metadata and controls
35 lines (26 loc) · 899 Bytes
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
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
export default function (eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight, {
});
// Create a collection for blog posts
eleventyConfig.addCollection("posts", function (collectionApi) {
// Try both possible paths depending on build context
const blogPosts = collectionApi.getFilteredByGlob("blog/posts/*.md");
const posts = collectionApi.getFilteredByGlob("posts/*.md");
// Return whichever one has results
return blogPosts.length > 0 ? blogPosts : posts;
});
// Add date filter for formatting dates
eleventyConfig.addFilter("date", function (date, format) {
if (!date) return "";
const d = new Date(date);
if (format === "%B %d, %Y") {
return d.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
}
return d.toLocaleDateString();
});
};