#Have dynamic content in HTML comment
1 messages · Page 1 of 1 (latest)
Astro allows you to use JavaScript expressions within your HTML templates. However, these expressions must be enclosed in curly braces { }. In your case, you are trying to use a variable commitSha inside an HTML comment.
Astro might not be evaluating the JavaScript expression inside the HTML comment because comments are usually ignored by HTML parsers.
If you want to include dynamic content in your HTML, you can do it outside of the comment. Here's an example of how you can use JavaScript expressions in Astro:
---const items = ["Dog", "Cat", "Platypus"];---
<ul>
{items.map((item) => (
<li>{item}</li>
))}
</ul>
In this example, the items array is mapped to create an unordered list of items. Each item is enclosed in curly braces to tell Astro that it's a JavaScript expression.
If you still want to include the SHA in a comment for some reason, you might need to use a different approach or a workaround, as it seems like Astro doesn't support this directly.