fix: consolidate multiple module.exports in eleventy.config.js
All checks were successful
Deploy to Cloudflare Pages / publish (push) Successful in 46s
All checks were successful
Deploy to Cloudflare Pages / publish (push) Successful in 46s
This commit is contained in:
parent
c28f8f3198
commit
de4f0de089
1 changed files with 9 additions and 10 deletions
|
|
@ -3,24 +3,23 @@ module.exports = function(eleventyConfig) {
|
|||
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
|
||||
.sort((a, b) => b.date - a.date);
|
||||
});
|
||||
|
||||
// 2. Collection: The current (newest) published edition for the index page
|
||||
// 2. Collection: The current (newest) published edition
|
||||
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
|
||||
// 3. Layout aliases
|
||||
eleventyConfig.addLayoutAlias("edition", "layouts/edition.njk");
|
||||
eleventyConfig.addLayoutAlias("article", "layouts/article.njk");
|
||||
eleventyConfig.addLayoutAlias("base", "layouts/base.njk");
|
||||
|
||||
// 4. Force UTC date formatting to fix the 5-hour timezone shift
|
||||
// 4. Filters
|
||||
eleventyConfig.addFilter("newsDate", function(dateObj) {
|
||||
return new Date(dateObj).toLocaleDateString('en-US', {
|
||||
timeZone: 'UTC',
|
||||
|
|
@ -31,7 +30,6 @@ module.exports = function(eleventyConfig) {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
eleventyConfig.addFilter("roman", function(num) {
|
||||
const lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};
|
||||
let roman = '';
|
||||
|
|
@ -40,14 +38,15 @@ module.exports = function(eleventyConfig) {
|
|||
roman += i;
|
||||
num -= lookup[i];
|
||||
}
|
||||
} return roman; }
|
||||
);
|
||||
}
|
||||
return roman;
|
||||
});
|
||||
|
||||
module.exports = function(eleventyConfig) {
|
||||
// 5. Directory configuration (integrated into the same function)
|
||||
return {
|
||||
dir: {
|
||||
input: "content",
|
||||
includes: "../_includes", // Keeps templates safely outside the content dir
|
||||
includes: "../_includes",
|
||||
output: "dist"
|
||||
},
|
||||
templateFormats: ["md", "njk", "html"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue