11ty / eleventy-plugin-webc

Adds support for WebC *.webc files to Eleventy
https://www.11ty.dev/docs/languages/webc/
119 stars 10 forks source link

Accessing page data in a layout requires $data sometimes #78

Open darthmall opened 1 year ago

darthmall commented 1 year ago

There is one case in the layouts for https://11ty.webc.fun where I have to use $data.page.date instead of page.date. If I understand correctly, $data should only be necessary inside of components, not inside of templates.

https://github.com/darthmall/11ty.webc.fun/blob/main/src/_includes/layouts/plain.webc#L9

In the exact same layout, I’m able to put <p @text="page.data"></p> right above the line with <time :@value="$data.page.date"> and the paragraph renders the stringified date just fine.

I haven’t been able to create a repro for this, I’m afraid. It may have something to do with using a component inside the layout (I’ve created time.webc for formatting dates). It may also be related to https://github.com/11ty/webc/issues/152.