From 32c698c39a9b1c0b4d0dfaad8fdb6cb363924514 Mon Sep 17 00:00:00 2001 From: itsfinniii <102350242+itsfinniii@users.noreply.github.com> Date: Fri, 3 Apr 2026 22:33:41 +0200 Subject: [PATCH] Update some metadata for the photo category page --- astro/src/components/photos/Category.astro | 2 +- astro/src/content/photos/albums.ts | 2 +- astro/src/content/photos/categories.ts | 24 ++++++++++++++++++++ astro/src/graphql/photos/getCategory.graphql | 17 ++++++++++++++ astro/src/lib/pages.ts | 6 +++-- astro/src/pages/[...route].astro | 14 +++--------- astro/src/types/photos/album.d.ts | 2 +- 7 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 astro/src/graphql/photos/getCategory.graphql diff --git a/astro/src/components/photos/Category.astro b/astro/src/components/photos/Category.astro index 7b386c4..bf5ec87 100644 --- a/astro/src/components/photos/Category.astro +++ b/astro/src/components/photos/Category.astro @@ -11,7 +11,7 @@ interface Props { const category = Astro.props.category; const settings = await getSettings(); -const categoryAlbums = await getCategoryAlbums(settings, category.category); +const categoryAlbums = await getCategoryAlbums(settings, category.category.url); console.log(categoryAlbums); --- diff --git a/astro/src/content/photos/albums.ts b/astro/src/content/photos/albums.ts index cd7cdd8..ba7324b 100644 --- a/astro/src/content/photos/albums.ts +++ b/astro/src/content/photos/albums.ts @@ -239,7 +239,7 @@ export async function getCategoryAlbums(settings: GlobalSettings, route: string) const client = await createDirectusConnection(); const result = await client.query(print(getCategoryAlbumQuery), { date: formatDate(new Date(), "%Y-%M-%D"), - categoryUrl: `/${route}` + categoryUrl: route }); let albums: PhotoAlbum[] = []; diff --git a/astro/src/content/photos/categories.ts b/astro/src/content/photos/categories.ts index 83cfd15..a211aaa 100644 --- a/astro/src/content/photos/categories.ts +++ b/astro/src/content/photos/categories.ts @@ -1,6 +1,7 @@ import { createDirectusConnection } from "@/lib/directus"; import { print } from "graphql"; import getCategories from '@/graphql/photos/getCategories.graphql'; +import getCategory from '@/graphql/photos/getCategory.graphql'; export async function getAllCategories(settings: GlobalSettings): Promise { const client = await createDirectusConnection(); @@ -23,3 +24,26 @@ export async function getAllCategories(settings: GlobalSettings): Promise { + const client = await createDirectusConnection(); + const result = await client.query(print(getCategory), { + url: url + }); + + const item = result["Photo_Categories"][0]; + + let categories: PhotoAlbumCategory = { + id: item["id"], + title: item["title"], + url: item["url"], + thumbnail: { + url: item["thumbnail"]["filename_disk"], + width: item["thumbnail"]["width"], + height: item["thumbnail"]["height"] + } + }; + + return categories; +} + diff --git a/astro/src/graphql/photos/getCategory.graphql b/astro/src/graphql/photos/getCategory.graphql new file mode 100644 index 0000000..9ad2b5e --- /dev/null +++ b/astro/src/graphql/photos/getCategory.graphql @@ -0,0 +1,17 @@ +query getAllCategories($url: String!) { + Photo_Categories(filter: { status: { _eq: "published" }, url: { _eq: $url } }) { + id, + date_created, + date_updated, + status, + title, + url, + thumbnail { + id, + created_on, + filename_disk, + width, + height + } + } +} diff --git a/astro/src/lib/pages.ts b/astro/src/lib/pages.ts index a20b7c9..b04abad 100644 --- a/astro/src/lib/pages.ts +++ b/astro/src/lib/pages.ts @@ -1,7 +1,7 @@ import { getBlog } from "@/content/blogs/blogs"; import { getWebpage } from "@/content/pages/pages"; import { getAlbum } from "@/content/photos/albums"; -import { getAllCategories } from "@/content/photos/categories"; +import { getAllCategories, getPhotoCategory } from "@/content/photos/categories"; import { getPhotoFromHash } from "@/content/photos/photos"; import { getProject } from "@/content/projects/projects"; @@ -117,13 +117,15 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< params[key] = match[i + 1]; }); + const category = await getPhotoCategory(`/${params["C"]}`); + return { route: route, pageType: "PhotoCategory", page: { type: "PhotoCategory", exists: true, - category: params["C"], + category: category, pageNumber: params["page"] !== undefined ? Number(params["page"]) : 1 } }; diff --git a/astro/src/pages/[...route].astro b/astro/src/pages/[...route].astro index de330c8..fbdc181 100644 --- a/astro/src/pages/[...route].astro +++ b/astro/src/pages/[...route].astro @@ -152,11 +152,7 @@ if (page === null || page.page === null || !page.page.exists) { allowCrawlers: true, canonical: null, priority: 65, - thumbnail: { - url: page.page.category.thumbnail.url, - width: 1200, - height: 630 - } + thumbnail: page.page.category.thumbnail }}}> @@ -167,16 +163,12 @@ if (page === null || page.page === null || !page.page.exists) { { page.pageType === "PhotoCategory" && ( diff --git a/astro/src/types/photos/album.d.ts b/astro/src/types/photos/album.d.ts index 13ea2ad..e7f2c47 100644 --- a/astro/src/types/photos/album.d.ts +++ b/astro/src/types/photos/album.d.ts @@ -35,6 +35,6 @@ type PhotoCategory = { type: "PhotoCategory"; exists: boolean; - category: string; + category: PhotoAlbumCategory; pageNumber: number; }