commit 6b3322ef369d8e7f33fa18271e733bd6d59c1e84
parent 58b7e27960268978a99472c3b79b0f2e7fd0e531
Author: Luke Jones <luke.jones.2567@gmail.com>
Date: Tue, 21 Jul 2026 19:34:39 +0100
refactor: update expected data structure
Diffstat:
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/pages/photos/[id].astro b/src/pages/photos/[id].astro
@@ -7,9 +7,9 @@ import { getCollection, render } from "astro:content";
export async function getStaticPaths() {
const photos = await getCollection("photos");
- return photos.map((photo) => ({
+ return photos[0].data.map((photo) => ({
params: {
- id: photo.id,
+ id: photo.id.toString(),
},
props: {
photo,
@@ -22,22 +22,22 @@ const { photo } = Astro.props;
const photoSourceUrl = "/photos/source/";
const photoExtension = ".jpg";
-const photoPath = `${photoSourceUrl}${photo.data.id}${photoExtension}`;
+const photoPath = `${photoSourceUrl}${photo.id}${photoExtension}`;
const tableData = {
- "Location": photo.data.location,
- "Coordinates": photo.data.coordinates,
- "Tags": photo.data.tags
+ "Location": photo.location,
+ "Coordinates": photo.coordinates,
+ "Tags": photo.tags
}
---
-<Base title={photo.data.date}>
+<Base title={photo.date}>
<div class="flex flex-col gap-4">
<a href={photoPath}>
- <img src={photoPath} alt={photo.data.desc} />
+ <img src={photoPath} alt={photo.desc} />
</a>
<div class="flex flex-col gap-1">
- <span>{photo.data.desc}</span>
- <span>{photo.data.date}</span>
+ <span>{photo.desc}</span>
+ <span>{photo.date}</span>
</div>
<div>
<Table rows={tableData} />
diff --git a/src/pages/photos/index.astro b/src/pages/photos/index.astro
@@ -12,12 +12,12 @@ const photoViewUrl = "/photos/";
const photoThumbUrl = "/photos/thumb/";
const photoExtension = ".jpg";
-const contentData = photos.map((photo) => ({
- desc: `${photo.data.date}`,
- link: `${photoViewUrl}${photo.data.id}`,
+const contentData = photos[0].data.map((photo) => ({
+ desc: `${photo.date}`,
+ link: `${photoViewUrl}${photo.id}`,
image: {
- link: `${photoThumbUrl}${photo.data.id}${photoExtension}`,
- alt: `${photo.data.desc}`
+ link: `${photoThumbUrl}${photo.id}${photoExtension}`,
+ alt: `${photo.desc}`
}
}));
---