thegetty / quire

A multi-package repository for the Quire multiformat publishing framework
https://quire.getty.edu/
BSD 3-Clause "New" or "Revised" License
93 stars 12 forks source link

Fix issue where not assigning `classes` in front matter of a layout was breaking the build #855

Closed anderspollack closed 11 months ago

anderspollack commented 11 months ago

When creating a new publication with https://github.com/thegetty/quire-starter-objects-test/ things index front matter things/index.md using objects-page layout needs to set classes:

classes:
  - something

If you remove classes from things/index.md, the build fails because _layouts/objects-page.webc does not set classes in the layout front matter which all other layouts do.

This is the error when classes is not defined (when I remove it from the things index front matter things/index.md): [11ty] classes.filter is not a function (via TypeError)

This is odd because classes=[] is given a default value in the eleventyComputed classes function signature, so it should still filter over an empty array. But when logging classes I see this:

...
[ <1 empty item> ]
[ <1 empty item> ]
[ <2 empty items> ]
[ <1 empty item> ]
...

It's unclear where these empty items are coming from, but when I log Array.from(classes), I see:

...
[]
[ 'quire-contents' ]
[ 'half-title-page' ]
[ 'title-page' ]
[ 'quire-splash', 'page-one' ]
[ 'quire-cover' ]
[ 'quire-page', 'copyright-page' ]
[ 'quire-page' ]
...