Comments for date formatting [skip ci]
This commit is contained in:
parent
cb9fa305e1
commit
58310f43b0
@ -67,7 +67,7 @@ module.exports = function(eleventyConfig) {
|
|||||||
if(runMode === "serve" || runMode === "watch") {
|
if(runMode === "serve" || runMode === "watch") {
|
||||||
process.env.BUILD_DRAFTS = true;
|
process.env.BUILD_DRAFTS = true;
|
||||||
|
|
||||||
// Only log once
|
// Only log once.
|
||||||
if(!logged) {
|
if(!logged) {
|
||||||
console.log( "[11ty/eleventy-base-blog] including `draft: true` posts" );
|
console.log( "[11ty/eleventy-base-blog] including `draft: true` posts" );
|
||||||
}
|
}
|
||||||
@ -78,12 +78,13 @@ module.exports = function(eleventyConfig) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
eleventyConfig.addFilter("readableDate", (dateObj, format = "dd LLLL yyyy") => {
|
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
|
||||||
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat(format);
|
// 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) => {
|
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');
|
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user