From 6a14aca8ff3a0167b2a7e6d92ec3ed60415f46b5 Mon Sep 17 00:00:00 2001 From: itsfinniii <102350242+itsfinniii@users.noreply.github.com> Date: Sun, 15 Mar 2026 22:16:07 +0100 Subject: [PATCH] Support album-based photo lookup & routing --- astro/src/content/photos/photos.ts | 14 ++++++++++---- astro/src/graphql/photos/getPhotos.graphql | 4 ++-- astro/src/lib/pages.ts | 1 - .../pages/{index.astro => [...route].astro} | 19 ++++++++++++++++--- 4 files changed, 28 insertions(+), 10 deletions(-) rename astro/src/pages/{index.astro => [...route].astro} (56%) diff --git a/astro/src/content/photos/photos.ts b/astro/src/content/photos/photos.ts index 40a9770..584ed39 100644 --- a/astro/src/content/photos/photos.ts +++ b/astro/src/content/photos/photos.ts @@ -5,18 +5,22 @@ import md5 from "md5"; export async function getPhotoFromHash(albumUrl: string, hash: string): Promise { const client = await createDirectusConnection(); - const result = await client.query(print(getPhotos)); + const result = await client.query(print(getPhotos), { + albumUrl: albumUrl + }); + + let object: PhotoAlbumPhoto | null = null; result["Photo_Albums"][0]["photos"].forEach((photo: any) => { const hashObject = md5(JSON.stringify({ id: photo.id, - url: photo.photo.url, + url: photo.photo.filename_disk, width: photo.photo.width, height: photo.photo.height })); - if (hash.substring(hash.length - 10) === hash) { - return { + if (hashObject.substring(hashObject.length - 10) === hash) { + object = { id: photo.id, text: photo.text, photo: { @@ -27,4 +31,6 @@ export async function getPhotoFromHash(albumUrl: string, hash: string): Promise< } } }); + + return object; } diff --git a/astro/src/graphql/photos/getPhotos.graphql b/astro/src/graphql/photos/getPhotos.graphql index 85d79a0..456f8d6 100644 --- a/astro/src/graphql/photos/getPhotos.graphql +++ b/astro/src/graphql/photos/getPhotos.graphql @@ -1,5 +1,5 @@ -query getPhotos { - Photo_Albums(sort: ["-start_date", "-date_created"], filter: { status: { _eq: "published" }, url: { _eq: "/mirai-nexus-2026" }, category: { Photo_Categories_id: { status: { _eq: "published" } } } }) { +query getPhotos($albumUrl: String!) { + Photo_Albums(sort: ["-start_date", "-date_created"], filter: { status: { _eq: "published" }, url: { _eq: $albumUrl }, category: { Photo_Categories_id: { status: { _eq: "published" } } } }) { id, date_created, date_updated, diff --git a/astro/src/lib/pages.ts b/astro/src/lib/pages.ts index a6ff368..695e962 100644 --- a/astro/src/lib/pages.ts +++ b/astro/src/lib/pages.ts @@ -148,7 +148,6 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< params[key] = match[i + 1]; }); - console.log(params); const photo = await getPhotoFromHash(`/${params["R"]}`, params["H"]); if (photo === null) {} diff --git a/astro/src/pages/index.astro b/astro/src/pages/[...route].astro similarity index 56% rename from astro/src/pages/index.astro rename to astro/src/pages/[...route].astro index 67572b5..cbcf8f9 100644 --- a/astro/src/pages/index.astro +++ b/astro/src/pages/[...route].astro @@ -4,13 +4,26 @@ import { getPage } from "@/lib/pages"; import { getSettings } from "@/content/settings/settings" import WebpageLayout from "@/layouts/WebpageLayout.astro"; +export async function getStaticPaths() { + const settings = await getSettings(); + const pages = await getAllRoutesList(settings); + + console.log(pages); + + let routes: any[] = []; + + pages.forEach((page) => { + routes.push({ params: { route: page } }); + }) + + return routes; +} + const settings = await getSettings(); const routes = await getAllRoutesList(settings); -console.log(routes); const page = await getPage(settings, "/album/2026/mirai-nexus-2026/6c0e4453ab"); -console.log(page); ---

Test

-
\ No newline at end of file +