Add Photo Album pages
This commit is contained in:
@@ -1,19 +1,23 @@
|
|||||||
---
|
---
|
||||||
import { getAlbumRoute, getPhotoRoute } from '@/lib/routing';
|
import { getPhotoRoute } from '@/lib/routing';
|
||||||
import { AlbumPhotos } from './Album.tsx';
|
import { AlbumPhotos } from './Album.tsx';
|
||||||
import { getImageSize, getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
import { getSettings } from '@/content/settings/settings';
|
import { getSettings } from '@/content/settings/settings';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
album: PhotoAlbum;
|
page: PhotoAlbumPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = await getSettings();
|
const settings = await getSettings();
|
||||||
const album = Astro.props.album;
|
const album = Astro.props.page;
|
||||||
|
const pageNumber = Astro.props.page.pageNumber;
|
||||||
|
|
||||||
|
const startNumber = (pageNumber - 1) * settings.photo.album.perPage;
|
||||||
|
const endNumber = pageNumber * settings.photo.album.perPage;
|
||||||
|
|
||||||
const remappedPhotos: PhotoAlbumGalleryItem[] = [];
|
const remappedPhotos: PhotoAlbumGalleryItem[] = [];
|
||||||
|
|
||||||
album.photos.forEach((photo) => {
|
album.photos.slice(startNumber, endNumber).forEach((photo) => {
|
||||||
const resizedImage = getImageSize(photo.photo.width, photo.photo.height, 0.67);
|
const resizedImage = getImageSize(photo.photo.width, photo.photo.height, 0.67);
|
||||||
|
|
||||||
remappedPhotos.push({
|
remappedPhotos.push({
|
||||||
|
|||||||
@@ -147,7 +147,10 @@ export async function getPage(settings: GlobalSettings, route: string): Promise<
|
|||||||
return {
|
return {
|
||||||
route: route,
|
route: route,
|
||||||
pageType: "PhotoAlbum",
|
pageType: "PhotoAlbum",
|
||||||
page: photoAlbum
|
page: {
|
||||||
|
...photoAlbum,
|
||||||
|
pageNumber: params["page"] !== undefined ? Number(params['page']) : 1
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Photograph
|
// Photograph
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ if (page === null || page.page === null || !page.page.exists) {
|
|||||||
thumbnail: page.page.category.thumbnail
|
thumbnail: page.page.category.thumbnail
|
||||||
}}}>
|
}}}>
|
||||||
<Fragment slot="content">
|
<Fragment slot="content">
|
||||||
<AlbumPage album={page.page} />
|
<AlbumPage page={page.page} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</WebpageLayout>
|
</WebpageLayout>
|
||||||
) }
|
) }
|
||||||
|
|||||||
2
astro/src/types/pages/page.d.ts
vendored
2
astro/src/types/pages/page.d.ts
vendored
@@ -41,6 +41,6 @@ type PageType =
|
|||||||
| { pageType: "ProjectPost"; page: ProjectPost; route: string }
|
| { pageType: "ProjectPost"; page: ProjectPost; route: string }
|
||||||
| { pageType: "PhotoCategoryIndex"; page: PhotoCategoryIndex; route: string }
|
| { pageType: "PhotoCategoryIndex"; page: PhotoCategoryIndex; route: string }
|
||||||
| { pageType: "PhotoCategory"; page: PhotoCategory; route: string }
|
| { pageType: "PhotoCategory"; page: PhotoCategory; route: string }
|
||||||
| { pageType: "PhotoAlbum"; page: PhotoAlbum; route: string }
|
| { pageType: "PhotoAlbum"; page: PhotoAlbumPage; route: string }
|
||||||
| { pageType: "Photo"; page: PhotoPage; route: string }
|
| { pageType: "Photo"; page: PhotoPage; route: string }
|
||||||
| { pageType: "Unknown"; page: null; route: string };
|
| { pageType: "Unknown"; page: null; route: string };
|
||||||
|
|||||||
23
astro/src/types/photos/album.d.ts
vendored
23
astro/src/types/photos/album.d.ts
vendored
@@ -20,6 +20,29 @@ type PhotoAlbum = {
|
|||||||
lastModified: Date;
|
lastModified: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PhotoAlbumPage = {
|
||||||
|
type: "PhotoAlbum";
|
||||||
|
exists: boolean;
|
||||||
|
pageNumber: number;
|
||||||
|
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
title: string;
|
||||||
|
url: string;
|
||||||
|
description: string | null;
|
||||||
|
|
||||||
|
thumbnail: PhotoProps;
|
||||||
|
|
||||||
|
startDate: string;
|
||||||
|
endDate: string | null;
|
||||||
|
location: string | null;
|
||||||
|
|
||||||
|
category: PhotoAlbumCategory;
|
||||||
|
photos: PhotoAlbumPhoto[];
|
||||||
|
|
||||||
|
lastModified: Date;
|
||||||
|
}
|
||||||
|
|
||||||
type PhotoAlbumCategory = {
|
type PhotoAlbumCategory = {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user