2026-03-24 14:24:04 +00:00
|
|
|
module.exports = function (eleventyConfig) {
|
|
|
|
|
// Collection: all posts sorted by date descending
|
|
|
|
|
eleventyConfig.addCollection("posts", function (collectionApi) {
|
|
|
|
|
return collectionApi
|
2026-03-24 14:40:10 +00:00
|
|
|
.getFilteredByGlob("src/blog/posts/**/*.md")
|
2026-03-24 14:24:04 +00:00
|
|
|
.sort((a, b) => b.date - a.date);
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-24 17:29:44 +00:00
|
|
|
// Collection: about window content
|
|
|
|
|
eleventyConfig.addCollection("aboutContent", (api) =>
|
|
|
|
|
api.getFilteredByGlob("src/about.md")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Collection: projects, sorted alphabetically by title
|
|
|
|
|
eleventyConfig.addCollection("projects", (api) =>
|
|
|
|
|
api
|
|
|
|
|
.getFilteredByGlob("src/projects/**/*.md")
|
|
|
|
|
.filter((p) => !p.fileSlug.startsWith("_"))
|
|
|
|
|
.sort((a, b) => a.data.title.localeCompare(b.data.title))
|
|
|
|
|
);
|
|
|
|
|
|
2026-03-24 14:24:04 +00:00
|
|
|
// Filter: human-readable date, e.g. "March 24, 2026"
|
|
|
|
|
eleventyConfig.addFilter("readableDate", function (date) {
|
|
|
|
|
return new Date(date).toLocaleDateString("en-US", {
|
|
|
|
|
year: "numeric",
|
|
|
|
|
month: "long",
|
|
|
|
|
day: "numeric",
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Filter: aggregate tags across a post collection
|
|
|
|
|
// Returns [{tag, count}, ...] sorted by count desc, excluding "posts"
|
|
|
|
|
eleventyConfig.addFilter("tagCounts", function (posts) {
|
|
|
|
|
const counts = {};
|
|
|
|
|
for (const post of posts) {
|
|
|
|
|
for (const tag of post.data.tags || []) {
|
|
|
|
|
if (tag === "posts") continue;
|
|
|
|
|
counts[tag] = (counts[tag] || 0) + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Object.entries(counts)
|
|
|
|
|
.map(([tag, count]) => ({ tag, count }))
|
|
|
|
|
.sort((a, b) => b.count - a.count);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Pass through static assets
|
2026-03-24 17:29:44 +00:00
|
|
|
eleventyConfig.addPassthroughCopy("src/assets");
|
2026-03-24 14:24:04 +00:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
dir: {
|
2026-03-24 14:40:10 +00:00
|
|
|
input: "src",
|
2026-03-24 14:24:04 +00:00
|
|
|
output: "_site",
|
|
|
|
|
includes: "_includes",
|
|
|
|
|
data: "_data",
|
|
|
|
|
},
|
|
|
|
|
templateFormats: ["njk", "md", "html"],
|
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
|
};
|
|
|
|
|
};
|