From 9020c458500dbcea66093aa2a9e9ff1b7502c2ab Mon Sep 17 00:00:00 2001 From: Shawn Thompson Date: Mon, 16 Sep 2024 10:45:20 -0400 Subject: [PATCH] add filter to show full date --- .eleventy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.eleventy.js b/.eleventy.js index f786fcbcb..70d100d70 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -109,12 +109,22 @@ module.exports = function (eleventyConfig) { return collection.filter((item) => item.data.locale === locale); }); + // Specific postDate filter for blog posts or other content with strict formatting eleventyConfig.addFilter("postDate", (dateObj) => { return DateTime.fromJSDate(dateObj, { zone: "utc" }) .setLocale("en") .toFormat("yyyy'-'MM'-'dd"); }); + // Format date filter to display full date + eleventyConfig.addFilter("formatDate", function (dateObj) { + const locale = this.ctx.locale || 'en'; // Use the locale from the context, default to 'en' + + return DateTime.fromJSDate(dateObj, { zone: "utc" }) + .setLocale(locale) + .toLocaleString(DateTime.DATE_MED); // Use DATE_MED to exclude the day of the week + }); + eleventyConfig.addPassthroughCopy({ "./src/_docs": "docs" }); eleventyConfig.addPassthroughCopy({ "./src/_images": "img" }); eleventyConfig.addPassthroughCopy({ "./src/CNAME": "CNAME" });