front-matter icon indicating copy to clipboard operation
front-matter copied to clipboard

Frontmatter date parsing oddities

Open williamwgant opened this issue 3 years ago • 3 comments

Greetings, I have a markdown file that has a date frontmatter field that expects the date in YYYY-MM-DD format. When I read the data out using front-matter (for instance, using the date '2021-04-01'), I get the date with a bunch of other crap in there. It seems to be actually parsing the date and adjusting for timezone, so in the previous instance I get 'Wed Mar 31 2021 19:00:00 GMT-0500 (Central Daylight Time)'. Is there a way to tell it not to try and infer the type without changing the format (which I can't do without breaking a lot of other stuff)? I really just need the raw text value.

williamwgant avatar May 15 '21 13:05 williamwgant

Same happened to me. I investigated and the problem appears to be that front-matter uses js-yaml with the default DEFAULT_SCHEMA which includes automatic detection of dates. It would be better to use CORE_SCHEMA or to pass through a schema option to js-yaml.

Toxaris avatar Nov 28 '21 23:11 Toxaris

I’m having the same issue.

Is there a way to set the js-yaml CORE_SCHEMA?

mjgs avatar May 03 '23 11:05 mjgs

I opened a related issue on the js-yaml repo , posting here in case it’s useful to others that run into something similar.

mjgs avatar May 06 '23 11:05 mjgs