Add support for formatting ISO dates
This commit is contained in:
parent
18d99cfe6c
commit
d48a11c9a2
|
@ -12,8 +12,12 @@ export default function(eleventyConfig) {
|
|||
});
|
||||
|
||||
// Format dates
|
||||
eleventyConfig.addFilter("formatDate", (dateObj) => {
|
||||
return DateTime.fromJSDate(dateObj).toFormat("d LLLL yyyy");
|
||||
eleventyConfig.addFilter("formatDate", (date) => {
|
||||
const dateFormat = "d LLLL yyyy";
|
||||
if (typeof date === "object") {
|
||||
return DateTime.fromJSDate(date).toFormat(dateFormat);
|
||||
}
|
||||
return DateTime.fromISO(date, { setZone: true }).toFormat(dateFormat);
|
||||
});
|
||||
|
||||
// Limit number of items displayed
|
||||
|
|
Loading…
Reference in New Issue