ludovicchabant / PieCrust2

A simple yet powerful static website generator and lightweight CMS
Other
43 stars 8 forks source link

PieCrust chokes if page YAML frontmatter contains dates #37

Closed innermatrix closed 6 years ago

innermatrix commented 7 years ago

I have some pages which specify their creation time in their YAML front matter, and PieCrust is choking on them.

The gist of the problem is that YAML parser comes back with datetime.date objects, which PieCrust then tries to serialize cache by converting them to JSON. JSON doesn't know what to do with dates, so PieCrust dies.

I am fixing this with two changes: first, I switched the cache to use YAML for serialization instead of JSON, because things that YAML can serialize are pretty much a superset of things that JSON can serialize.

Second, some metadata parsing code was assuming that dates in metadata would always be strings and had to be converted to dates, so it had to be adjusted to allow receiving dates straight up.

ludovicchabant commented 7 years ago

Hey, thanks for the PR. I'm worried about performance though -- IIRC yaml serialization is quite slower than the built-in json one, but I'll have to run some tests to check that.

Can you post some examples of front matters that crash PieCrust? thanks.