32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
|
|
module.exports = function(eleventyConfig) {
|
||
|
|
// 1. Collection: All published editions, newest first
|
||
|
|
eleventyConfig.addCollection("publishedEditions", function(collectionApi) {
|
||
|
|
return collectionApi.getFilteredByGlob("content/editions/*/index.md")
|
||
|
|
.filter(item => item.data.status === "published")
|
||
|
|
.sort((a, b) => b.date - a.date); // Sort descending
|
||
|
|
});
|
||
|
|
|
||
|
|
// 2. Collection: The current (newest) published edition for the index page
|
||
|
|
eleventyConfig.addCollection("currentEdition", function(collectionApi) {
|
||
|
|
const published = collectionApi.getFilteredByGlob("content/editions/*/index.md")
|
||
|
|
.filter(item => item.data.status === "published")
|
||
|
|
.sort((a, b) => b.date - a.date);
|
||
|
|
|
||
|
|
return published.length > 0 ? [published[0]] : [];
|
||
|
|
});
|
||
|
|
|
||
|
|
// 3. Layout aliases so you don't have to type the full path in front matter
|
||
|
|
eleventyConfig.addLayoutAlias("edition", "layouts/edition.njk");
|
||
|
|
eleventyConfig.addLayoutAlias("article", "layouts/article.njk");
|
||
|
|
eleventyConfig.addLayoutAlias("base", "layouts/base.njk");
|
||
|
|
|
||
|
|
return {
|
||
|
|
dir: {
|
||
|
|
input: "content",
|
||
|
|
includes: "../_includes", // Keeps templates safely outside the content dir
|
||
|
|
output: "dist"
|
||
|
|
},
|
||
|
|
templateFormats: ["md", "njk", "html"]
|
||
|
|
};
|
||
|
|
};
|