withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
502 stars 59 forks source link

Closing HTML tag getting removed when there's a component above #957

Open diamond-fish opened 9 months ago

diamond-fish commented 9 months ago

Astro Info

Astro                    v4.3.1
Node                     v18.19.0
System                   Windows (x64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap

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

No response

Describe the Bug

Steps to reproduce:

  1. Clone https://github.com/robertguss/Astro-Theme-Creek
  2. Update Astro to v4.3.1
  3. Start dev server (npm run dev)
  4. Observe the issue: the </title> tag is missing

From what I can see, if you remove <GoogleAnalytics /> inside BaseHead.astro, then it fixes the issue, which suggests this issue only crops up when a component is added. This issue still exists even if GoogleAnalytics.astro is empty.

What's the expected result?

The </title> tag should be present. Because it's missing, it's causing some side effects, such as the Google Fonts not loading. The H1 font should look like this:

https://astro-theme-creek.netlify.app/

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-2bvud4-crhr4g

Participation

MoustaphaDev commented 9 months ago

Thanks for reporting this! This looks like a regression in the compiler, I'll investigate this further early next week. In the meantime, you could wrap the title element in an expression as a workaround.

{<title>{title}</title>}

Sorry for the trouble!