-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Datetime widget is wrapping date in single quotes #1271
Comments
@charlotte-l Can you check what CMS version this happened in? Has it just been since v1.5.0? If you aren't sure what version it changed in, please try v1.3.1 and v1.4.0 as well. |
@tech4him1 I believe we intentionally dropped the date type from the yaml parser right? Looks like some SSG's need it after all. Hadn't thought much about type requirements in output until this started being reported. |
Oh okay, gotcha. So that's tough - the date widget was supposed to be returning a string the whole time, the documented default value, but was instead returning the same default value as |
|
I use the date field to sort data inside my Jekyll collection. Having dates within '' breaks Jekyll build process. Please address this issue soon, unable to use the CMS because of this |
@tech4him1 yep it's definitely that PR - folks have been relying on two bugs this whole time. This line used to evaluate true if:
When both of these conditions are met, a Date object was returned, but since that PR, a format is always provided by the widget, so a date object is never returned. Defining the breaking changeCurrently, the documented behavior is that the date widget returns a formatted string, but the experience of most users is that it returns a date object. I'm inclined to consider returning to the documented behavior as a breaking change, since that's the net impact for most users. Dates should not be stringsHere's another thing: Most users should never need a formatted date string. I don't know why I didn't realize this sooner - their templates will apply formatting via their static site generator. Formatting the string from the CMS is probably an edge case. ProposalBecause the prior behavior was so iffy, I'd rather us improve from where we are to address this rather than simply revert the commit at fault. The desired behavior should be:
Thoughts? |
We'll also need to note which file formats will serialize to a string anyway. YAML and TOML have an explicit Date format, but JSON doesn't. |
- Do you want to request a feature or report a bug?
Bug
- What is the current behavior?
Dates generated by the Datetime widget are wrapped in single quotes in the document's front matter.
Example:
date: '2018-03-21T11:14:49+00:00'
- If the current behavior is a bug, please provide the steps to reproduce.
No other front matter fields which we are using are subject to this issue.
- What is the expected behavior?
Previously the date was not wrapped in single quotes. As the date is now interpreted as a string, this breaks interactions with metalsmith (which requires dates to be in a date format, not as a string).
Example:
date: 2018-03-21T11:14:49+00:00
- Please mention your CMS, node.js, and operating system version.
Netlify CMS v1.5.0
The text was updated successfully, but these errors were encountered: