From 58310f43b0c579287fc3631d80f4508bc88c3943 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 23 Jan 2023 17:04:23 -0600 Subject: [PATCH] Comments for date formatting [skip ci] --- eleventy.config.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eleventy.config.js b/eleventy.config.js index e0fef82..5267771 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -67,7 +67,7 @@ module.exports = function(eleventyConfig) { if(runMode === "serve" || runMode === "watch") { process.env.BUILD_DRAFTS = true; - // Only log once + // Only log once. if(!logged) { console.log( "[11ty/eleventy-base-blog] including `draft: true` posts" ); } @@ -78,12 +78,13 @@ module.exports = function(eleventyConfig) { }) // Filters - eleventyConfig.addFilter("readableDate", (dateObj, format = "dd LLLL yyyy") => { - return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat(format); + eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => { + // Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens + return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy"); }); - // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string eleventyConfig.addFilter('htmlDateString', (dateObj) => { + // dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); });