Skip to content

CSS / Script being injected into body in some circumstances #6700

@darusk

Description

@darusk

What version of astro are you using?

2.1.7

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Windows

What browser are you using?

Chrome, Firefox

Describe the Bug

In a certain circumstance when using a component in an MDX file, the css and script links are being injected into the body of the final page at the point where the component is, instead of the head.

All pages in the example are basically the same, pulling in a simple component which takes an optional title. If the title is passed in an MDX file, the css & scripts get injected where the component starts. If the title is not given or the file is an .astro file, it gets injected into the head where it should be.

After going through all the releases from a time when it worked as expected up to recent, it came down to an update in version 2.1.6 (possibly 7daef9a29?)

Unfortunately my JS skills are extremely limited so cannot dig further!

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-hu9zun?file=src/pages/index.mdx

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

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