From 91b771863378912def16eb339afbdc88cbd1ad84 Mon Sep 17 00:00:00 2001 From: sirlilpanda Date: Tue, 28 Jul 2026 22:48:33 +1200 Subject: [PATCH] pages that creates all the albums --- src/pages/pictures/[id].astro | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/pages/pictures/[id].astro diff --git a/src/pages/pictures/[id].astro b/src/pages/pictures/[id].astro new file mode 100644 index 0000000..b52df6e --- /dev/null +++ b/src/pages/pictures/[id].astro @@ -0,0 +1,37 @@ +--- +// useful https://jankraus.net/2024/04/05/how-to-build-a-simple-photo-gallery-with-astro/ +import { type CollectionEntry, getCollection, } from 'astro:content'; +import Album from '../../layouts/Album.astro'; +import { Image } from 'astro:assets'; +export const prerender = true; + + +async function getAlbumImages(id : any) { + let images = import.meta.glob<{default : ImageMetadata}>("/src/assets/pictures/**/*.png") + images = Object.fromEntries(Object.entries(images).filter(([key]) => key.includes(id))); + const resolvedImages = await Promise.all(Object.values(images).map((image) => image().then((mod) => mod.default))); + return resolvedImages; +} + +export async function getStaticPaths() { + const albums = await getCollection('album'); + + return albums.map((album) => { + return { + params: {id: album.id,}, + props: album , + } + }) +} + +type Props = CollectionEntry<'album'>; + +const album = Astro.props; + +const images = await getAlbumImages(album.id); +// console.log(images) +--- + + + {images.map((image) => )} +