Didnt actually add gitignore last time... oops. Adding it here w/ a new
eleventy.js.
This commit is contained in:
parent
955a330ad9
commit
d9436941fe
2 changed files with 49 additions and 0 deletions
47
.eleventy.js
Normal file
47
.eleventy.js
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
module.exports = function (eleventyConfig) {
|
||||||
|
// Collection: all posts sorted by date descending
|
||||||
|
eleventyConfig.addCollection("posts", function (collectionApi) {
|
||||||
|
return collectionApi
|
||||||
|
.getFilteredByGlob("blog/posts/**/*.md")
|
||||||
|
.sort((a, b) => b.date - a.date);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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
|
||||||
|
eleventyConfig.addPassthroughCopy("assets");
|
||||||
|
|
||||||
|
return {
|
||||||
|
dir: {
|
||||||
|
input: ".",
|
||||||
|
output: "_site",
|
||||||
|
includes: "_includes",
|
||||||
|
data: "_data",
|
||||||
|
},
|
||||||
|
templateFormats: ["njk", "md", "html"],
|
||||||
|
markdownTemplateEngine: "njk",
|
||||||
|
htmlTemplateEngine: "njk",
|
||||||
|
};
|
||||||
|
};
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules/
|
||||||
|
_site/
|
||||||
Loading…
Reference in a new issue