Support javascript dates in pubDate alongside RFC 822 formats #186
Replies: 2 comments 2 replies
-
Thanks to the internal YAML parser, the following formats are "natively" supported: pubDate: February 5, 2023 12:00 PM
pubDate: February 5, 2023
pubDate: Feb 5, 2023 Just tried with the simple blog template and the date was updated live via hot-reloading. |
Beta Was this translation helpful? Give feedback.
-
@tipiirai It's easy to get false negative or positives from tests, since the string values can give unexpected results. |
Beta Was this translation helpful? Give feedback.
-
For discussion (I don't have a strong opinion on this)
Support javascript dates in pubDate alongside RFC 822 formats
The rationale for this is to make the creation of markdown files as well as the editing of front matter be an activity more accessible and friendly for non developers. So that a new blog post front matter could be
Instead of
This would alleviate the need to use a pretty date control when referring to the
pubDate
in layouts.This only requires the following change (plus a few small other changes for some other edge cases, but it's not a lot.
I actually added this to my own layout.html because I wanted to keep the dates in the more human readible format since my semi-dyslexia means I can't easily see the difference between a group of numbers, but having the month as a word helps me hugely tell the difference when scanning text.
I'm ok if I have to stick to RFC 822, but it got me thinking how many other people / users are similar to me?
Perhaps we can simply expose a post.prettyDate or post.Date property that keeps either value.
We can detect whether a user has specified either value, and set the other accordingly.
e.g.
would automatically set pubDate to
2020-01-20
and also date to20 Jan 2020
? And vice versa.I think as we expand collections, this type of smart meta data would avoid users writing custom pretty formattings for different display uses?
NB! : The pretty date is actually javascript compatible. new date('1 Jan 2024`) is valid.
Beta Was this translation helpful? Give feedback.
All reactions