color-js / elements

WIP
14 stars 1 forks source link

[website] Components' pages don't have titles #43

Closed DmitrySharabin closed 6 months ago

DmitrySharabin commented 6 months ago

Niether <h1>

image

nor <title> (the generic one is used)

image
DmitrySharabin commented 6 months ago

The debugging showed that the title computed property defined here

https://github.com/color-js/elements/blob/8f25296080ab1939dc31967b6b726e95f196af86/_includes/component.njk#L18-L20

returns an empty string.

For some reason, data.title is an empty string.

The investigation is to be continued...

DmitrySharabin commented 6 months ago

Since data.title is an empty string but data.tag is not, we can fix (at least temporarily) the issue with this change (see line 19 above):

+ return data.title ?? data.tag;
- return data.title || data.tag;
DmitrySharabin commented 6 months ago

But why is data.title empty on component pages but not on the root page? The root page uses the page.njk layout. This layout uses the default computed property title defined in _data/eleventyComputed.js (it extracts the default title from the content).

However, the layout, which uses component pages (component.njk), re-defined the title property to use either the title provided by the component (none of them is doing it) or the computed property tag (defined in the same block).