diff --git a/astro/src/content/photos/photos.ts b/astro/src/content/photos/photos.ts index ccb864a..baa0876 100644 --- a/astro/src/content/photos/photos.ts +++ b/astro/src/content/photos/photos.ts @@ -3,13 +3,13 @@ import { print } from "graphql"; import getPhotos from '@/graphql/photos/getPhotos.graphql'; import md5 from "md5"; -export async function getPhotoFromHash(albumUrl: string, hash: string): Promise { +export async function getPhotoFromHash(albumUrl: string, hash: string): Promise { const client = await createDirectusConnection(); const result = await client.query(print(getPhotos), { albumUrl: albumUrl }); - let object: PhotoAlbumPhoto | null = null; + let object: PhotoAlbumItem | null = null; result["Photo_Albums"][0]["photos"].forEach((photo: any) => { /* @@ -29,9 +29,13 @@ export async function getPhotoFromHash(albumUrl: string, hash: string): Promise< id: photo.id, text: photo.text, photo: { - url: photo.photo.url, + url: photo.photo.filename_disk, width: photo.photo.width, height: photo.photo.height + }, + album: { + url: result["Photo_Albums"][0].url, + title: result["Photo_Albums"][0].title } } } diff --git a/astro/src/lib/pages.ts b/astro/src/lib/pages.ts index b04abad..d3f9a6d 100644 --- a/astro/src/lib/pages.ts +++ b/astro/src/lib/pages.ts @@ -175,7 +175,8 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< id: photo!.id, photo: photo!.photo, - text: photo!.text + text: photo!.text, + album: photo!.album } }; } diff --git a/astro/src/pages/[...route].astro b/astro/src/pages/[...route].astro index 65630fd..c4cc05b 100644 --- a/astro/src/pages/[...route].astro +++ b/astro/src/pages/[...route].astro @@ -12,6 +12,7 @@ import BlogPost from "@/components/blogs/BlogPost.astro"; import ProjectPost from "@/components/projects/ProjectPost.astro"; import CategoryIndex from "@/components/photos/CategoryIndex.astro"; import Category from "@/components/photos/Category.astro"; +import { getImageUrl } from "@/lib/images"; export async function getStaticPaths() { const settings = await getSettings(); @@ -145,19 +146,19 @@ if (page === null || page.page === null || !page.page.exists) { { page.pageType === "Photo" && ( -
{page.page.id}
+
{JSON.stringify(page.page)}
) } diff --git a/astro/src/types/photos/album.d.ts b/astro/src/types/photos/album.d.ts index e7f2c47..5fd39b6 100644 --- a/astro/src/types/photos/album.d.ts +++ b/astro/src/types/photos/album.d.ts @@ -38,3 +38,13 @@ type PhotoCategory = { category: PhotoAlbumCategory; pageNumber: number; } + +type PhotoAlbumItem = { + id: string; + photo: PhotoProps; + text: string | null; + album: { + url: string; + title: string; + }; +} diff --git a/astro/src/types/photos/photo.d.ts b/astro/src/types/photos/photo.d.ts index 030fae6..d217a3b 100644 --- a/astro/src/types/photos/photo.d.ts +++ b/astro/src/types/photos/photo.d.ts @@ -5,4 +5,8 @@ type PhotoPage = { id: string; photo: PhotoProps; text: string | null; + album: { + url: string; + title: string; + }; }