Fix some more routing related things
This commit is contained in:
@@ -28,6 +28,7 @@ export async function getAllAlbums(settings: GlobalSettings): Promise<PhotoAlbum
|
||||
endDate: albumRecord["end_date"],
|
||||
location: albumRecord["location"],
|
||||
category: {
|
||||
id: albumRecord["category"][0]["Photo_Categories_id"]["id"],
|
||||
title: albumRecord["category"][0]["Photo_Categories_id"]["title"],
|
||||
url: albumRecord["category"][0]["Photo_Categories_id"]["url"],
|
||||
thumbnail: {
|
||||
|
||||
25
astro/src/content/photos/categories.ts
Normal file
25
astro/src/content/photos/categories.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createDirectusConnection } from "@/lib/directus";
|
||||
import { print } from "graphql";
|
||||
import getCategories from '@/graphql/photos/getCategories.graphql';
|
||||
|
||||
export async function getAllCategories(settings: GlobalSettings): Promise<PhotoAlbumCategory[]> {
|
||||
const client = await createDirectusConnection();
|
||||
const result = await client.query(print(getCategories));
|
||||
|
||||
let categories: PhotoAlbumCategory[] = [];
|
||||
|
||||
result["Photo_Categories"].forEach((photoCategoryRecord: any) => {
|
||||
categories.push({
|
||||
id: photoCategoryRecord["id"],
|
||||
title: photoCategoryRecord["title"],
|
||||
url: photoCategoryRecord["url"],
|
||||
thumbnail: {
|
||||
url: photoCategoryRecord["thumbnail"]["filename_disk"],
|
||||
width: photoCategoryRecord["thumbnail"]["width"],
|
||||
height: photoCategoryRecord["thumbnail"]["height"]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return categories;
|
||||
}
|
||||
Reference in New Issue
Block a user