Skip to content

Create new component manager per page #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CanIGetaPR
Copy link

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

Fixes #174

Create new component manager per page so webc:setup blocks get appropriate per-page contexts
@Zearin
Copy link
Contributor

Zearin commented May 10, 2023

@zachleat This PR needs approval.

And love.

Loving approval. ❤️👍🏽

@agarzola
Copy link

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

@hasanhaja
Copy link

hasanhaja commented Sep 4, 2023

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

@PersonMeetup
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scoped Webc Functions Lose Correct Page Context
5 participants