Cause
The problem resides within Page.prototype.prepareTemplateData. If a siteNav is not explicitly declared within the frontmatter of a page, the associated CSS files will not be inserted into the page.
Bug found in #527
If a
siteNavis not explicitly declared within thefrontmatterof a page, the associated CSS files will not be inserted into the page.
That sounds bad. This means that when a Page needs to deal with site navigation, it has to worry that the siteNav may come from different sources (either from the frontmatter or from a layout), and all the methods have to be consistent with such dealings (and in this case, Page.prototype.prepareTemplateData failed to be consistent with the rest of the methods).
From the viewpoint of the Page, it should not matter where the siteNav comes from (whether it being from the frontmatter or a layout). Perhaps there should be a redesign, such that (1) any overrides are resolved once, and (2) methods in Page do not have to deal with the overrides, just with the final resolved value.
The fix can be rather simple, by creating a boolean function to check a Page's frontmatter and layout if any site navigation was specified.
I have similar logic within inserting page navigation (with its own CSS file), I will try to push updated commits today for page navigation, to check layouts as well as front matter
@amad-person @Chng-Zhi-Xuan are either of you currently working on this issue? I have some time these couple of days and can jump in to work on it if nobody else is currently doing it!
@marvinchin I haven't started on it, you can go ahead!
Most helpful comment
@marvinchin I haven't started on it, you can go ahead!