lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.76k stars 75 forks source link

Allow other ISO 8601 date representations in `date` field #272

Closed paulrobertlloyd closed 1 year ago

paulrobertlloyd commented 1 year ago

Pages can only include dates in the following formats:

This appears to follow RFC 3339. However, IS0 8601 dates typically don’t include spaces, but instead use T to separate the date and time. For example, the above can also be represented as:

Support for this representation in Lume would be useful as it would make migrating pages from an Eleventy-powered blog easier. For reference, Eleventy supports thew following date formats:

It should be noted that Luke’s date format filters support both of the above representations (ATOM and DATETIME).

ISO 8601 dates also don’t need to include - or : separators, so the following dates are also valid:

There may be less need to support this, although I’be come across it on my own site where I’m parsing iCalendar data which formats dates using this representation. As I can’t use them directly when generating pages, I need to manipulate them to the format Lume allows.

oscarotero commented 1 year ago

Deno' std modules include some datetime utils, like this parser; https://deno.land/std@0.157.0/datetime/mod.ts?s=parse but it doesn't auto-detect the format. Maybe the date-fns library (a already used dependency) can handle these formats.

I like also the git related dates of Eleventy. It's something that @dz4k implemented in his site: https://github.com/dz4k/denizaksimsek.com/blob/master/_build/get-dates-from-git.ts