Skip to content
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

Content Layer API inserts scripts from all collection entries into every generated page #12024

Open
1 task
jurajkapsz opened this issue Sep 18, 2024 · 4 comments
Labels
needs repro Issue needs a reproduction

Comments

@jurajkapsz
Copy link
Contributor

jurajkapsz commented Sep 18, 2024

Astro Info

Astro                    v4.15.6
Node                     v20.11.1
System                   Linux (x64)
Package Manager          pnpm
Output                   hybrid
Adapter                  @astrojs/node
Integrations             @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Switched to Content Layer API, having content collections with mdx files that include and call various [astro] components in their content.

---
frontmatter...
---

import SomeComponent from "@components/some-component.astro";

Lorem ....

<SomeComponent/>

[astro] components can have scripts and styles.

When browsing website, I see scripts basically from all components included and executed on every page, even if they are not part of given page content.

What's the expected result?

Only those assets should be part of the page that are included in content or template. This worked with Content Collections.

Link to Minimal Reproducible Example

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Sep 18, 2024
@florian-lefebvre florian-lefebvre added the needs repro Issue needs a reproduction label Sep 19, 2024
Copy link
Contributor

Hello @jurajkapsz. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Sep 19, 2024
@jurajkapsz
Copy link
Contributor Author

Should I rather create an Astro 5 beta minimal reproduction, if any? Will be Content Layer API non-experimental also for Astro v4?

@ascorbic
Copy link
Contributor

This should be fixed with #12014. It will be in a release soon. Thanks for the report!

@jurajkapsz
Copy link
Contributor Author

OK, thanks very much @ascorbic !

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

No branches or pull requests

3 participants