Regarding <Image/> from astro:assets. I currently have two locations where I'm using the frontmatter image src with Image to generate a webp. One is in a blog article layout, the other is in a Card.astro component. Doing so creates two of the same image. This isn't really ideal, so I'm wondering how I can reference the image generated in the layout file from the Card component. I thought that it may be possible to set the card img src programatically if I could calculate the build hash, or by customizing the output filename. Is this the best/only way to achieve what I want to do?
#Accessing assets:content <Image/> created in one component from another
5 messages · Page 1 of 1 (latest)
Still waiting for an answer?
It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.
If the props passed to the <Image> component are the exact same (excluding alt), it should generate only one file during the build.
Are you sure you do not have a propthat differs?
Thanks so much @strong reef. You're right, the props differed. I was styling it differently with a class prop. To get around it I've used getImage and then styled the result via an img tag. Is this the best way to do it?
class or class:list should also not affect the final file; if it does, it seems like a bug. I'll run some tests later.