webc icon indicating copy to clipboard operation
webc copied to clipboard

Create new component manager per page

Open CanIGetaPR opened this issue 1 year ago • 4 comments

Create new component manager per page so webc:setup blocks get appropriate per-page contexts

Fixes #174

CanIGetaPR avatar May 02 '23 22:05 CanIGetaPR

@zachleat This PR needs approval.

And love.

Loving approval. ❤️👍🏽

Zearin avatar May 10 '23 23:05 Zearin

I applied the patch in this PR to my project and confirmed that it solves #174 and 11ty/eleventy-plugin-webc#69.

agarzola avatar Aug 10 '23 07:08 agarzola

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

hasanhaja avatar Sep 04 '23 08:09 hasanhaja

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">&larr; Previous Day</a>
    <a webc:if="next" :href="next.url">Next Day &rarr;</a>
</nav>
<!-- . . . -->
<p @html="this.content"></p>

PersonMeetup avatar Oct 10 '23 19:10 PersonMeetup