I have been trying to import frontmatter into css with Astro and cannot figure out how to put it into the css. I need it to work this way because I am trying to be able to update a background image for each item through the markdown file.
Card.astro
---
const allvideos = await Astro.glob("../content/videos/*.md");
---
{
allvideos.map((video) => (
<div class="mb-4 col-md-6">
<div class="h-100 p-5 text-light rounded-3 background">
<h2>{video.frontmatter.name}</h2>
<p>{video.frontmatter.desc}</p>
<a class="btn btn-outline-light btn-lg" type="button" href={video.frontmatter.link} target="_blank">Watch Now</a>
</div>
</div>
))
}
<style>
.background {
min-height: 100%;
background: linear-gradient(0deg, rgb(0, 0, 0, 0.8), rgb(24, 24, 24, 0.8)),
url(../images/{video.frontmatter.image});
background-size: cover;
background-position: center;
}
</style>
Markdown File
---
name: "Name"
desc: "Description"
link: link
image: imagename.webp
---