-
-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eleventy Does not Accept Valid YAML Datetimes in Front Matter #3220
Comments
Additional Context#1669 is related: it mentions similar flexible date parsing, but in the context of a feature request, not noting that the requested behavior is actually already within the documented (if not actual) behavior. As noted in the comments of the issue above, Eleventy uses Luxon under the hood to parse the "date" front matter key. This may represent a change in Luxon's behavior in favor of stricter ISO parsing between the writing of the relevant Eleventy documentation and now, but I did not go so far as to check the histories of Luxon and the docs. |
YAML dates are unquoted, no? We only use Luxon when the |
Related #867 |
|
Operating system
Fedora Linux 38
Eleventy
2.0.1
Describe the bug
Eleventy does not accept all valid YAML datetimes in the
date
key of template front matters.Per the Eleventy Content Dates documentation, Eleventy should allow any valid YAML date as a value for the "date" front matter key. Per the linked YAML timestamp documentation, whitespace separation of the date, time, and timezone sections of the timestamp are valid for YAML (note specifically the "Regex" and "Example 1" sections).
However, this is not reflected in Eleventy's behavior; datetimes which are valid for YAML but not for ISO 8601 cause an error, e.g.:
date: "2024-01-01T00:00:00" # valid ISO 8601, valid in front matter
date: "2024-01-01T00:00:00-05" # valid ISO 8601, valid in front matter
date: "2024-01-01 00:00:00" # valid YAML datetime, invalid in front matter
date: "2024-01-01 00:00:00 -5" # valid YAML datetime, invalid in front matter
date: "2024-01-01 00:00:00 -05" # valid YAML datetime, invalid in front matter
Reproduction steps
In your template's front matter, use a valid YAML datetime that is not a valid (strict) ISO 8601 datetime due to whitespace, e.g.:
date: "2024-01-01 00:00:00"
date: "2024-01-01 00:00:00 -5"
date: "2024-01-01 00:00:00 -05"
Expected behavior
Any valid YAML datetime should be valid for the Eleventy "date" front matter key, or the Eleventy documentation should be updated to reflect the actual behavior.
Reproduction URL
No response
Screenshots
N/A
The text was updated successfully, but these errors were encountered: