mirror of
https://github.com/helenclx/leilukin-site.git
synced 2025-04-03 20:40:51 +00:00
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…
x
Reference in New Issue
Block a user