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: #1049

Open
lifeisfakenews opened this issue Oct 31, 2024 · 1 comment
Open

🐛 BUG: #1049

lifeisfakenews opened this issue Oct 31, 2024 · 1 comment
Labels
- P2: has workaround Bug, but has workaround (priority)

Comments

@lifeisfakenews
Copy link

What version of @astrojs/compiler are you using?

2.10.3

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

The document title gets split in a way it shouldnt when using ternarys

The code

---
interface Props {
  title?: string;
}
const { title } = Astro.props;
---
<!doctype html>
<html lang="en">
  <head>
    ... other head ...        
    <meta name="generator" content={Astro.generator} />
    <title>{title ? `${title} - ` : ""}Doctor 9 Tutoring</title>
  </head>
  <body class="dark">
    ...
 </body>
</html>

Will produce a site where the document/page title is <title> - (title is the correct value as passed to the component), and first child of the body would be "Doctor 9 Tutoring", rather than being correctly wrapped within the <title> tag. I did also notice that the is not being returned, however the content of the body is returned when looking at the network tab.
image

It works fine however if i put {title} - Doctor 9 Tutoring in the <title> tag instead

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-jsi3lg?file=src%2Fpages%2Fwith-title.astro

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Oct 31, 2024
@MoustaphaDev
Copy link
Member

As a workaround you could wrap the title tag in an expression, or by adding a space after the closing brace as mentioned in #1058

@MoustaphaDev MoustaphaDev added the - P2: has workaround Bug, but has workaround (priority) label Jan 19, 2025
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jan 19, 2025
@MoustaphaDev MoustaphaDev marked this as a duplicate of #1058 Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority)
Projects
None yet
Development

No branches or pull requests

2 participants