-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
When MDX contains an Astro component, script tags are not placed in head #6181
Comments
I'll take a look. Meanwhile, if you use a layout this likely won't occur. |
This happened on my personal site with a layout, too. I ended up not using the component and just using html+markdown, so no pressure from me, but I figured I'd report it for posterity. |
I am encountering the same issue. Using mdx with content collection, the .mdx file has imported .astro components and I render the md inside a Layout.astro file using Astro 2.0.9 using vercel adapter. |
@angelokeirsebilck that scenario might be different (likely is). If you could create a stackblitz and share it with me, I'll take a look. |
@matthewp I could not create a stackblitz but managed to make a minimal repo (starting from the blog starter) to reproduce the error. https://github.com/angelokeirsebilck/mdx-collection-vercel-head-misplacement The problem occurs when you import an .astro component inside mdx, and in that .astro component you import another .astro component. Bug occurs here https://github.com/angelokeirsebilck/mdx-collection-vercel-head-misplacement/blob/main/src/components/blocks/home/HomeBanner.astro#L14 EDIT: I tried to make a stackblitz but you cannot run preview with vercel adapter: https://stackblitz.com/edit/github-nrmyz2?file=src/content/blog/bug.mdx |
What version of
astro
are you using?2.0.9
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
If you have an MDX page that imports an Astro component, all of the
<script>
tags are placed right before that imported component in the DOM instead of inside<head>
. It's very strange. It does not happen with the MDX article in the official blog template that uses a content collection. I suspect it only happens with a regular file path-based route.I was able to create a minimal reproduction. The problem can be seen on the
/test/
page.Link to Minimal Reproducible Example
https://codesandbox.io/p/sandbox/inspiring-goldberg-wuwq0f?on=codesandbox&file=%2Fsrc%2Fpages%2Ftest%2Findex.mdx&selection=%5B%7B%22endColumn%22%3A16%2C%22endLineNumber%22%3A18%2C%22startColumn%22%3A16%2C%22startLineNumber%22%3A18%7D%5D
Participation
The text was updated successfully, but these errors were encountered: