#How do I use an astro component in a template literal?
2 messages · Page 1 of 1 (latest)
Astro doesn't support using components directly inside template literals. Instead, you should use the Astro component syntax within the HTML part of your Astro file.
Here's how you can use the TheFlameUpgrades component in your Astro file:
---
import TheFlameUpgrades from "@components/TheFlame/TheFlameUpgrades.astro";
let entryData = { upgrades: true }; // assuming you have entryData defined somewhere
---
{entryData.upgrades ?
<div class="more-items">
<div class="title">{t("view-upgrades")}:</div>
<TheFlameUpgrades flameAltar={/* pass your props here */} />
</div>
: ""}
In this example, the TheFlameUpgrades component is used directly in the HTML part of the Astro file. The ternary operator (? :) is used to conditionally render the div containing the TheFlameUpgrades component based on the entryData.upgrades value.