Compare commits
2 Commits
5c161b8381
...
b73066352e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b73066352e | ||
|
|
f95f792775 |
@@ -12,8 +12,6 @@ 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.url);
|
const categoryAlbums = await getCategoryAlbums(settings, category.category.url);
|
||||||
|
|
||||||
console.log(categoryAlbums);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -59,15 +59,12 @@ export async function getAllAlbums(settings: GlobalSettings): Promise<PhotoAlbum
|
|||||||
};
|
};
|
||||||
|
|
||||||
albumRecord["photos"].forEach((photoRecord: any) => {
|
albumRecord["photos"].forEach((photoRecord: any) => {
|
||||||
const imageSize =
|
|
||||||
getImageSize(photoRecord["photo"]["width"], photoRecord["photo"]["height"], 0.8);
|
|
||||||
|
|
||||||
album.photos.push({
|
album.photos.push({
|
||||||
id: photoRecord["id"],
|
id: photoRecord["id"],
|
||||||
photo: {
|
photo: {
|
||||||
url: photoRecord["photo"]["filename_disk"],
|
url: photoRecord["photo"]["filename_disk"],
|
||||||
width: imageSize.width,
|
width: photoRecord["photo"]["width"],
|
||||||
height: imageSize.height
|
height: photoRecord["photo"]["height"]
|
||||||
},
|
},
|
||||||
text: photoRecord["text"]
|
text: photoRecord["text"]
|
||||||
});
|
});
|
||||||
@@ -145,15 +142,12 @@ export async function getAlbum(settings: GlobalSettings, route: string): Promise
|
|||||||
};
|
};
|
||||||
|
|
||||||
albumRecord["photos"].forEach((photoRecord: any) => {
|
albumRecord["photos"].forEach((photoRecord: any) => {
|
||||||
const imageSize =
|
|
||||||
getImageSize(photoRecord["photo"]["width"], photoRecord["photo"]["height"], 0.8);
|
|
||||||
|
|
||||||
album.photos.push({
|
album.photos.push({
|
||||||
id: photoRecord["id"],
|
id: photoRecord["id"],
|
||||||
photo: {
|
photo: {
|
||||||
url: photoRecord["photo"]["filename_disk"],
|
url: photoRecord["photo"]["filename_disk"],
|
||||||
width: imageSize.width,
|
width: photoRecord["photo"]["width"],
|
||||||
height: imageSize.height
|
height: photoRecord["photo"]["height"]
|
||||||
},
|
},
|
||||||
text: photoRecord["text"]
|
text: photoRecord["text"]
|
||||||
});
|
});
|
||||||
@@ -228,15 +222,12 @@ export async function getLastAlbums(amount: number) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
albumRecord["photos"].forEach((photoRecord: any) => {
|
albumRecord["photos"].forEach((photoRecord: any) => {
|
||||||
const imageSize =
|
|
||||||
getImageSize(photoRecord["photo"]["width"], photoRecord["photo"]["height"], 0.8);
|
|
||||||
|
|
||||||
album.photos.push({
|
album.photos.push({
|
||||||
id: photoRecord["id"],
|
id: photoRecord["id"],
|
||||||
photo: {
|
photo: {
|
||||||
url: photoRecord["photo"]["filename_disk"],
|
url: photoRecord["photo"]["filename_disk"],
|
||||||
width: imageSize.width,
|
width: photoRecord["photo"]["width"],
|
||||||
height: imageSize.height
|
height: photoRecord["photo"]["height"]
|
||||||
},
|
},
|
||||||
text: photoRecord["text"]
|
text: photoRecord["text"]
|
||||||
});
|
});
|
||||||
@@ -323,8 +314,8 @@ export async function getCategoryAlbums(settings: GlobalSettings, route: string)
|
|||||||
id: photoRecord["id"],
|
id: photoRecord["id"],
|
||||||
photo: {
|
photo: {
|
||||||
url: photoRecord["photo"]["filename_disk"],
|
url: photoRecord["photo"]["filename_disk"],
|
||||||
width: imageSize.width,
|
width: photoRecord["photo"]["width"],
|
||||||
height: imageSize.height
|
height: photoRecord["photo"]["height"]
|
||||||
},
|
},
|
||||||
text: photoRecord["text"]
|
text: photoRecord["text"]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,19 +3,20 @@ import { print } from "graphql";
|
|||||||
import getPhotos from '@/graphql/photos/getPhotos.graphql';
|
import getPhotos from '@/graphql/photos/getPhotos.graphql';
|
||||||
import md5 from "md5";
|
import md5 from "md5";
|
||||||
|
|
||||||
export async function getPhotoFromHash(albumUrl: string, hash: string): Promise<PhotoAlbumPhoto | null> {
|
export async function getPhotoFromHash(albumUrl: string, hash: string): Promise<PhotoAlbumItem | null> {
|
||||||
const client = await createDirectusConnection();
|
const client = await createDirectusConnection();
|
||||||
const result = await client.query(print(getPhotos), {
|
const result = await client.query(print(getPhotos), {
|
||||||
albumUrl: albumUrl
|
albumUrl: albumUrl
|
||||||
});
|
});
|
||||||
|
|
||||||
let object: PhotoAlbumPhoto | null = null;
|
let object: PhotoAlbumItem | null = null;
|
||||||
|
|
||||||
result["Photo_Albums"][0]["photos"].forEach((photo: any) => {
|
result["Photo_Albums"][0]["photos"].forEach((photo: any) => {
|
||||||
/*
|
/*
|
||||||
* I have decided to not put the getImageSize here, it can mess up the
|
* I have decided to not put the getImageSize here, it can mess up the
|
||||||
* hashing, or anything else. It seems smarter to do this in the photo's and galleries.
|
* hashing, or anything else. It seems smarter to do this in the photo's and galleries.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const hashObject = md5(JSON.stringify({
|
const hashObject = md5(JSON.stringify({
|
||||||
id: photo.id,
|
id: photo.id,
|
||||||
url: photo.photo.filename_disk,
|
url: photo.photo.filename_disk,
|
||||||
@@ -28,9 +29,13 @@ export async function getPhotoFromHash(albumUrl: string, hash: string): Promise<
|
|||||||
id: photo.id,
|
id: photo.id,
|
||||||
text: photo.text,
|
text: photo.text,
|
||||||
photo: {
|
photo: {
|
||||||
url: photo.photo.url,
|
url: photo.photo.filename_disk,
|
||||||
width: photo.photo.width,
|
width: photo.photo.width,
|
||||||
height: photo.photo.height
|
height: photo.photo.height
|
||||||
|
},
|
||||||
|
album: {
|
||||||
|
url: result["Photo_Albums"][0].url,
|
||||||
|
title: result["Photo_Albums"][0].title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,8 @@ export async function getPage(settings: GlobalSettings, route: string): Promise<
|
|||||||
|
|
||||||
id: photo!.id,
|
id: photo!.id,
|
||||||
photo: photo!.photo,
|
photo: photo!.photo,
|
||||||
text: photo!.text
|
text: photo!.text,
|
||||||
|
album: photo!.album
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import BlogPost from "@/components/blogs/BlogPost.astro";
|
|||||||
import ProjectPost from "@/components/projects/ProjectPost.astro";
|
import ProjectPost from "@/components/projects/ProjectPost.astro";
|
||||||
import CategoryIndex from "@/components/photos/CategoryIndex.astro";
|
import CategoryIndex from "@/components/photos/CategoryIndex.astro";
|
||||||
import Category from "@/components/photos/Category.astro";
|
import Category from "@/components/photos/Category.astro";
|
||||||
|
import { getImageUrl } from "@/lib/images";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const settings = await getSettings();
|
const settings = await getSettings();
|
||||||
@@ -145,19 +146,19 @@ if (page === null || page.page === null || !page.page.exists) {
|
|||||||
{ page.pageType === "Photo" && (
|
{ page.pageType === "Photo" && (
|
||||||
<WebpageLayout settings={{
|
<WebpageLayout settings={{
|
||||||
searchEngine: {
|
searchEngine: {
|
||||||
title: "Projects",
|
title: page.page.album.title,
|
||||||
description: "",
|
description: `See this photo from the album ${page.page.album.title}`,
|
||||||
allowCrawlers: true,
|
allowCrawlers: true,
|
||||||
canonical: null,
|
canonical: null,
|
||||||
priority: 65,
|
priority: 65,
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: "",
|
url: getImageUrl(page.page.photo.url),
|
||||||
width: 1200,
|
width: page.page.photo.width,
|
||||||
height: 630
|
height: page.page.photo.height
|
||||||
}
|
}
|
||||||
}}}>
|
}}}>
|
||||||
<Fragment slot="content">
|
<Fragment slot="content">
|
||||||
<div>Photo</div>
|
<div>{JSON.stringify(page.page)}</div>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</WebpageLayout>
|
</WebpageLayout>
|
||||||
) }
|
) }
|
||||||
|
|||||||
10
astro/src/types/photos/album.d.ts
vendored
10
astro/src/types/photos/album.d.ts
vendored
@@ -38,3 +38,13 @@ type PhotoCategory = {
|
|||||||
category: PhotoAlbumCategory;
|
category: PhotoAlbumCategory;
|
||||||
pageNumber: number;
|
pageNumber: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PhotoAlbumItem = {
|
||||||
|
id: string;
|
||||||
|
photo: PhotoProps;
|
||||||
|
text: string | null;
|
||||||
|
album: {
|
||||||
|
url: string;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
4
astro/src/types/photos/photo.d.ts
vendored
4
astro/src/types/photos/photo.d.ts
vendored
@@ -5,4 +5,8 @@ type PhotoPage = {
|
|||||||
id: string;
|
id: string;
|
||||||
photo: PhotoProps;
|
photo: PhotoProps;
|
||||||
text: string | null;
|
text: string | null;
|
||||||
|
album: {
|
||||||
|
url: string;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user