Created
January 7, 2024 18:56
-
-
Save hamzamu/bc6643cae1eb6f866cc5cc269ad5291a to your computer and use it in GitHub Desktop.
gallery.astro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
import { Image } from 'astro:assets'; | |
const imageFiles = await Astro.glob('./images/*'); | |
--- | |
src: https://axellarsson.com/blog/load-all-images-in-a-directory-with-astro/ | |
<div class="columns-1 sm:columns-2 md:columns-3 lg:columns-4 gap-3 mb-5 mx-auto w-full px-4"> | |
{ | |
imageFiles.map((img) => ( | |
<Image | |
src={img.default} | |
width="600" | |
alt="Photo of a pizza" | |
class="mb-3 w-full rounded" | |
/> | |
)) | |
} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment