Is there a way to pass Props in the Style so that each component has a unique background image?
Take a look at this component:
countries.astro
---
import type { Props } from 'astro';
const { country, description } = Astro.props as Props;
---
<section>
<div>
<h1>{country}</h1>
<p>{description}</p>
</div>
</section>
<style>
section {
height: 100vh;
color: #fff;
}
div {
height: 100%;
width: 40%;
padding: 0 5% 0 10%;
display: flex;
flex-direction: column;
justify-content: center;
}
h1 {
font-size: 8rem;
}
</style>
Now, if you want to have different background images based on the country in the index file:
index.astro
---
import Countries from "../components/Countries.astro";
import Layout from "../layouts/Layout.astro";
---
<Layout title="Countries">
<Countries country="ITALY"/>
<Countries country="SPAIN"/>
<Countries country="GERMANY"/>
</Layout>
<style>
</style>
If you have any suggestions on how to achieve this, please let me know!
Thank you!