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

🐛 BUG: Astro deletes content injecting <head> & <body> #2132

Closed
jonathantneal opened this issue Dec 6, 2021 · 5 comments
Closed

🐛 BUG: Astro deletes content injecting <head> & <body> #2132

jonathantneal opened this issue Dec 6, 2021 · 5 comments
Milestone

Comments

@jonathantneal
Copy link
Contributor

jonathantneal commented Dec 6, 2021

What version of astro are you using?

0.21.10

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

While investigating #2128, I noticed similar issues when Astro injects <body>.

test-1.astro: Works!

---

---
<html lang="en">

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />

<title>Test 1</title>

<h1>Test 1</h1>

</html>

test-2.astro: Fails.

---
const H1 = 'h1'
---
<html lang="en">

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />

<title>Test 1</title>

<H1>Test 1</H1>

</html>

test-2/index.html: Rendered.

<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">

<title>Test 2</title>

<h1>undefined</h1>
</head><body>Test 2</body>

</html>

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ffn9hf

@natemoo-re
Copy link
Member

🤔 Looks like these are in src/pages, which is subject to our automatic head/body detection heuristics. There are discussions to move away from this behavior and rely on the behavior that occurs outside of src/pages and src/layouts. Would be very interested to see the output if these files used that behavior.

Not sure we could ever expect test-2.astro to work as you expect with the current behavior! How could the compiler differentiate between a component like MetaHead that you mean to be in the <head> and H1 that you mean to be in the <body>.

@jonathantneal
Copy link
Contributor Author

@natemoo-re, would this be resolved by #2193?

@tony-sull
Copy link
Contributor

Looks like this one would likely be part of the improvements for the RFC to finalize <head> and <body> behavior 👍

@natemoo-re
Copy link
Member

Thanks @tony-sull! This is on track to be fixed in withastro/compiler#267 and the subsequent 0.24.x release of astro.

@natemoo-re natemoo-re added this to the 0.24 milestone Mar 9, 2022
@natemoo-re
Copy link
Member

This should be fixed in the newly released [email protected]!

Please give feel free to reopen this issue if you're still having trouble.

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

No branches or pull requests

3 participants