Remove generateStaticParams
This commit is contained in:
parent
5279d651f7
commit
ad2ee85331
@ -11,7 +11,6 @@ import {
|
||||
} from '@/site/paths';
|
||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import { getPhotos, getUniqueFilmSimulations } from '@/services/postgres';
|
||||
import { ReactNode } from 'react';
|
||||
import { FilmSimulation } from '@/simulation';
|
||||
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
||||
@ -20,20 +19,6 @@ interface PhotoFilmSimulationProps {
|
||||
params: { photoId: string, simulation: FilmSimulation }
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: PhotoFilmSimulationProps[] = [];
|
||||
|
||||
const simulations = await getUniqueFilmSimulations();
|
||||
simulations.forEach(async ({ simulation }) => {
|
||||
const photos = await getPhotos({ simulation });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, simulation },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { photoId, simulation },
|
||||
}: PhotoFilmSimulationProps): Promise<Metadata> {
|
||||
|
||||
@ -1,31 +1,14 @@
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||
import { getPhotos, getUniqueFilmSimulations } from '@/services/postgres';
|
||||
import { FilmSimulation } from '@/simulation';
|
||||
import { PATH_ROOT } from '@/site/paths';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
interface PhotoFilmSimulationProps {
|
||||
params: { photoId: string, simulation: FilmSimulation }
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: PhotoFilmSimulationProps[] = [];
|
||||
|
||||
const simulations = await getUniqueFilmSimulations();
|
||||
simulations.forEach(async ({ simulation }) => {
|
||||
const photos = await getPhotos({ simulation });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, simulation },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export default async function Share({
|
||||
params: { photoId, simulation },
|
||||
}: PhotoFilmSimulationProps) {
|
||||
}: {
|
||||
params: { photoId: string, simulation: FilmSimulation }
|
||||
}) {
|
||||
const photo = await getPhotoCached(photoId);
|
||||
|
||||
if (!photo) { return redirect(PATH_ROOT); }
|
||||
|
||||
@ -12,20 +12,14 @@ import {
|
||||
} from '@/site/paths';
|
||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||
import { getPhotoCached, getPhotosCached } from '@/cache';
|
||||
import { getPhotos } from '@/services/postgres';
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const photos = await getPhotos();
|
||||
return photos.map(photo => ({
|
||||
params: { photoId: photo.id },
|
||||
}));
|
||||
interface PhotoProps {
|
||||
params: { photoId: string }
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { photoId },
|
||||
}: {
|
||||
params: { photoId: string }
|
||||
}): Promise<Metadata> {
|
||||
}:PhotoProps): Promise<Metadata> {
|
||||
const photo = await getPhotoCached(photoId);
|
||||
|
||||
if (!photo) { return {}; }
|
||||
@ -56,10 +50,8 @@ export async function generateMetadata({
|
||||
export default async function PhotoPage({
|
||||
params: { photoId },
|
||||
children,
|
||||
}: {
|
||||
params: { photoId: string }
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
}:
|
||||
PhotoProps & { children: React.ReactNode }) {
|
||||
const photo = await getPhotoCached(photoId);
|
||||
|
||||
if (!photo) { redirect(PATH_ROOT); }
|
||||
|
||||
@ -11,10 +11,6 @@ import {
|
||||
} from '@/site/paths';
|
||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import {
|
||||
getPhotos,
|
||||
getUniqueCameras,
|
||||
} from '@/services/postgres';
|
||||
import { cameraFromPhoto } from '@/camera';
|
||||
import { getPhotosCameraDataCached } from '@/camera/data';
|
||||
import { ReactNode } from 'react';
|
||||
@ -23,20 +19,6 @@ interface PhotoCameraProps {
|
||||
params: { photoId: string, camera: string }
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: PhotoCameraProps[] = [];
|
||||
|
||||
const cameras = await getUniqueCameras();
|
||||
cameras.forEach(async ({ cameraKey, camera }) => {
|
||||
const photos = await getPhotos({ camera });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, camera: cameraKey },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { photoId, camera },
|
||||
}: PhotoCameraProps): Promise<Metadata> {
|
||||
|
||||
@ -1,31 +1,14 @@
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import { cameraFromPhoto } from '@/camera';
|
||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||
import { getPhotos, getUniqueCameras } from '@/services/postgres';
|
||||
import { PATH_ROOT } from '@/site/paths';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
interface PhotoCameraParams {
|
||||
params: { photoId: string, camera: string }
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: PhotoCameraParams[] = [];
|
||||
|
||||
const cameras = await getUniqueCameras();
|
||||
cameras.forEach(async ({ cameraKey, camera }) => {
|
||||
const photos = await getPhotos({ camera });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, camera: cameraKey },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export default async function Share({
|
||||
params: { photoId, camera: cameraProp },
|
||||
}: PhotoCameraParams) {
|
||||
}: {
|
||||
params: { photoId: string, camera: string }
|
||||
}) {
|
||||
const photo = await getPhotoCached(photoId);
|
||||
|
||||
if (!photo) { return redirect(PATH_ROOT); }
|
||||
|
||||
@ -11,7 +11,6 @@ import {
|
||||
} from '@/site/paths';
|
||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import { getPhotos, getUniqueTags } from '@/services/postgres';
|
||||
import { getPhotosTagDataCached } from '@/tag/data';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
@ -19,20 +18,6 @@ interface PhotoTagProps {
|
||||
params: { photoId: string, tag: string }
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: PhotoTagProps[] = [];
|
||||
|
||||
const tags = await getUniqueTags();
|
||||
tags.forEach(async ({ tag }) => {
|
||||
const photos = await getPhotos({ tag });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, tag },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export async function generateMetadata({
|
||||
params: { photoId, tag },
|
||||
}: PhotoTagProps): Promise<Metadata> {
|
||||
|
||||
@ -1,30 +1,13 @@
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||
import { getPhotos, getUniqueTags } from '@/services/postgres';
|
||||
import { PATH_ROOT } from '@/site/paths';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
interface PhotoTagProps {
|
||||
params: { photoId: string, tag: string }
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const params: PhotoTagProps[] = [];
|
||||
|
||||
const tags = await getUniqueTags();
|
||||
tags.forEach(async ({ tag }) => {
|
||||
const photos = await getPhotos({ tag });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, tag },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export default async function Share({
|
||||
params: { photoId, tag },
|
||||
}: PhotoTagProps) {
|
||||
}: {
|
||||
params: { photoId: string, tag: string }
|
||||
}) {
|
||||
const photo = await getPhotoCached(photoId);
|
||||
|
||||
if (!photo) { return redirect(PATH_ROOT); }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user