webc
webc copied to clipboard
Create new component manager per page
Create new component manager per page so webc:setup blocks get appropriate per-page contexts
Fixes #174
@zachleat This PR needs approval.
And love.
Loving approval. ❤️👍🏽
I applied the patch in this PR to my project and confirmed that it solves #174 and 11ty/eleventy-plugin-webc#69.
I can confirm too that this solves my issue.
Applied patch: https://github.com/hasanhaja/site/blob/main/patches/%4011ty%2Bwebc%2B0.11.4.patch My layout: https://github.com/hasanhaja/site/blob/main/src/_includes/layouts/info.webc
It now correctly builds all of my pages with the layout info.webc
with the correct data
Can also verify the patch works! I was having issues rendering collection navigation within a .webc
template, due to the stale data issue this PR addresses. Small sample of the template's code follows:
<script webc:setup>
const previous = this.getPreviousCollectionItem(collections.apod);
const next = this.getNextCollectionItem(collections.apod);
</script>
<nav>
<a webc:if="previous" :href="previous.url">← Previous Day</a>
<a webc:if="next" :href="next.url">Next Day →</a>
</nav>
<!-- . . . -->
<p @html="this.content"></p>