Skip to content

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

@jurajkapsz

Description

@jurajkapsz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions