Compare commits
2 Commits
aa93600c79
...
f1b0d269bf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1b0d269bf | ||
|
|
32c698c39a |
@@ -11,7 +11,7 @@ interface Props {
|
|||||||
|
|
||||||
const category = Astro.props.category;
|
const category = Astro.props.category;
|
||||||
const settings = await getSettings();
|
const settings = await getSettings();
|
||||||
const categoryAlbums = await getCategoryAlbums(settings, category.category);
|
const categoryAlbums = await getCategoryAlbums(settings, category.category.url);
|
||||||
|
|
||||||
console.log(categoryAlbums);
|
console.log(categoryAlbums);
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ export async function getCategoryAlbums(settings: GlobalSettings, route: string)
|
|||||||
const client = await createDirectusConnection();
|
const client = await createDirectusConnection();
|
||||||
const result = await client.query(print(getCategoryAlbumQuery), {
|
const result = await client.query(print(getCategoryAlbumQuery), {
|
||||||
date: formatDate(new Date(), "%Y-%M-%D"),
|
date: formatDate(new Date(), "%Y-%M-%D"),
|
||||||
categoryUrl: `/${route}`
|
categoryUrl: route
|
||||||
});
|
});
|
||||||
|
|
||||||
let albums: PhotoAlbum[] = [];
|
let albums: PhotoAlbum[] = [];
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { createDirectusConnection } from "@/lib/directus";
|
import { createDirectusConnection } from "@/lib/directus";
|
||||||
import { print } from "graphql";
|
import { print } from "graphql";
|
||||||
import getCategories from '@/graphql/photos/getCategories.graphql';
|
import getCategories from '@/graphql/photos/getCategories.graphql';
|
||||||
|
import getCategory from '@/graphql/photos/getCategory.graphql';
|
||||||
|
|
||||||
export async function getAllCategories(settings: GlobalSettings): Promise<PhotoAlbumCategory[]> {
|
export async function getAllCategories(settings: GlobalSettings): Promise<PhotoAlbumCategory[]> {
|
||||||
const client = await createDirectusConnection();
|
const client = await createDirectusConnection();
|
||||||
@@ -23,3 +24,26 @@ export async function getAllCategories(settings: GlobalSettings): Promise<PhotoA
|
|||||||
|
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getPhotoCategory(url: string): Promise<PhotoAlbumCategory> {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
17
astro/src/graphql/photos/getCategory.graphql
Normal file
17
astro/src/graphql/photos/getCategory.graphql
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getBlog } from "@/content/blogs/blogs";
|
import { getBlog } from "@/content/blogs/blogs";
|
||||||
import { getWebpage } from "@/content/pages/pages";
|
import { getWebpage } from "@/content/pages/pages";
|
||||||
import { getAlbum } from "@/content/photos/albums";
|
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 { getPhotoFromHash } from "@/content/photos/photos";
|
||||||
import { getProject } from "@/content/projects/projects";
|
import { getProject } from "@/content/projects/projects";
|
||||||
|
|
||||||
@@ -117,13 +117,15 @@ export async function getPage(settings: GlobalSettings, route: string): Promise<
|
|||||||
params[key] = match[i + 1];
|
params[key] = match[i + 1];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const category = await getPhotoCategory(`/${params["C"]}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
route: route,
|
route: route,
|
||||||
pageType: "PhotoCategory",
|
pageType: "PhotoCategory",
|
||||||
page: {
|
page: {
|
||||||
type: "PhotoCategory",
|
type: "PhotoCategory",
|
||||||
exists: true,
|
exists: true,
|
||||||
category: params["C"],
|
category: category,
|
||||||
pageNumber: params["page"] !== undefined ? Number(params["page"]) : 1
|
pageNumber: params["page"] !== undefined ? Number(params["page"]) : 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,18 +42,8 @@ if (page === null || page.page === null || !page.page.exists) {
|
|||||||
|
|
||||||
{ page.page.type === "Webpage" && page.page.exists && (
|
{ page.page.type === "Webpage" && page.page.exists && (
|
||||||
<WebpageLayout settings={{
|
<WebpageLayout settings={{
|
||||||
searchEngine: {
|
searchEngine: page.page.searchEngine
|
||||||
title: page.page.searchEngine.title,
|
}}>
|
||||||
description: page.page.searchEngine.description,
|
|
||||||
allowCrawlers: page.page.searchEngine.allowCrawlers,
|
|
||||||
canonical: page.page.searchEngine.canonical,
|
|
||||||
priority: page.page.searchEngine.priority,
|
|
||||||
thumbnail: {
|
|
||||||
url: page.page.searchEngine.thumbnail.url,
|
|
||||||
width: 1200,
|
|
||||||
height: 630
|
|
||||||
}
|
|
||||||
}}}>
|
|
||||||
<Fragment slot="content">
|
<Fragment slot="content">
|
||||||
<Webpage webpage={page.page.components} />
|
<Webpage webpage={page.page.components} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
@@ -152,11 +142,7 @@ if (page === null || page.page === null || !page.page.exists) {
|
|||||||
allowCrawlers: true,
|
allowCrawlers: true,
|
||||||
canonical: null,
|
canonical: null,
|
||||||
priority: 65,
|
priority: 65,
|
||||||
thumbnail: {
|
thumbnail: page.page.category.thumbnail
|
||||||
url: page.page.category.thumbnail.url,
|
|
||||||
width: 1200,
|
|
||||||
height: 630
|
|
||||||
}
|
|
||||||
}}}>
|
}}}>
|
||||||
<Fragment slot="content">
|
<Fragment slot="content">
|
||||||
<CategoryIndex />
|
<CategoryIndex />
|
||||||
@@ -167,16 +153,12 @@ if (page === null || page.page === null || !page.page.exists) {
|
|||||||
{ page.pageType === "PhotoCategory" && (
|
{ page.pageType === "PhotoCategory" && (
|
||||||
<WebpageLayout settings={{
|
<WebpageLayout settings={{
|
||||||
searchEngine: {
|
searchEngine: {
|
||||||
title: "",
|
title: page.page.category.title,
|
||||||
description: "",
|
description: "",
|
||||||
allowCrawlers: true,
|
allowCrawlers: true,
|
||||||
canonical: null,
|
canonical: null,
|
||||||
priority: 65,
|
priority: 65,
|
||||||
thumbnail: {
|
thumbnail: page.page.category.thumbnail
|
||||||
url: "",
|
|
||||||
width: 1200,
|
|
||||||
height: 630
|
|
||||||
}
|
|
||||||
}}}>
|
}}}>
|
||||||
<Fragment slot="content">
|
<Fragment slot="content">
|
||||||
<Category category={page.page} />
|
<Category category={page.page} />
|
||||||
|
|||||||
2
astro/src/types/photos/album.d.ts
vendored
2
astro/src/types/photos/album.d.ts
vendored
@@ -35,6 +35,6 @@ type PhotoCategory = {
|
|||||||
type: "PhotoCategory";
|
type: "PhotoCategory";
|
||||||
exists: boolean;
|
exists: boolean;
|
||||||
|
|
||||||
category: string;
|
category: PhotoAlbumCategory;
|
||||||
pageNumber: number;
|
pageNumber: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user