From 39035bf188fb506d60ba95ccd385bb0f3bc632e9 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 11 Jan 2025 17:51:02 -0600 Subject: [PATCH] Remove all share pages/layouts --- .../film/[simulation]/[photoId]/layout.tsx | 91 ----------------- src/app/film/[simulation]/[photoId]/page.tsx | 90 ++++++++++++++++- .../[simulation]/[photoId]/share/page.tsx | 19 ---- src/app/film/[simulation]/share/page.tsx | 70 ------------- src/app/focal/[focal]/[photoId]/layout.tsx | 90 ----------------- src/app/focal/[focal]/[photoId]/page.tsx | 89 ++++++++++++++++- .../focal/[focal]/[photoId]/share/page.tsx | 21 ---- src/app/focal/[focal]/share/page.tsx | 74 -------------- src/app/p/[photoId]/layout.tsx | 84 ---------------- src/app/p/[photoId]/page.tsx | 83 +++++++++++++++- src/app/p/[photoId]/share/page.tsx | 18 ---- .../[make]/[model]/[photoId]/layout.tsx | 99 ------------------- .../shot-on/[make]/[model]/[photoId]/page.tsx | 98 +++++++++++++++++- .../[make]/[model]/[photoId]/share/page.tsx | 19 ---- src/app/shot-on/[make]/[model]/share/page.tsx | 70 ------------- src/app/tag/[tag]/[photoId]/layout.tsx | 84 ---------------- src/app/tag/[tag]/[photoId]/page.tsx | 83 +++++++++++++++- src/app/tag/[tag]/[photoId]/share/page.tsx | 18 ---- src/app/tag/[tag]/share/page.tsx | 71 ------------- 19 files changed, 433 insertions(+), 838 deletions(-) delete mode 100644 src/app/film/[simulation]/[photoId]/layout.tsx delete mode 100644 src/app/film/[simulation]/[photoId]/share/page.tsx delete mode 100644 src/app/film/[simulation]/share/page.tsx delete mode 100644 src/app/focal/[focal]/[photoId]/layout.tsx delete mode 100644 src/app/focal/[focal]/[photoId]/share/page.tsx delete mode 100644 src/app/focal/[focal]/share/page.tsx delete mode 100644 src/app/p/[photoId]/layout.tsx delete mode 100644 src/app/p/[photoId]/share/page.tsx delete mode 100644 src/app/shot-on/[make]/[model]/[photoId]/layout.tsx delete mode 100644 src/app/shot-on/[make]/[model]/[photoId]/share/page.tsx delete mode 100644 src/app/shot-on/[make]/[model]/share/page.tsx delete mode 100644 src/app/tag/[tag]/[photoId]/layout.tsx delete mode 100644 src/app/tag/[tag]/[photoId]/share/page.tsx delete mode 100644 src/app/tag/[tag]/share/page.tsx diff --git a/src/app/film/[simulation]/[photoId]/layout.tsx b/src/app/film/[simulation]/[photoId]/layout.tsx deleted file mode 100644 index b825eae1..00000000 --- a/src/app/film/[simulation]/[photoId]/layout.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { - RELATED_GRID_PHOTOS_TO_SHOW, - descriptionForPhoto, - titleForPhoto, -} from '@/photo'; -import { Metadata } from 'next/types'; -import { redirect } from 'next/navigation'; -import { - PATH_ROOT, - absolutePathForPhoto, - absolutePathForPhotoImage, -} from '@/site/paths'; -import PhotoDetailPage from '@/photo/PhotoDetailPage'; -import { ReactNode, cache } from 'react'; -import { FilmSimulation } from '@/simulation'; -import { - getPhotosMetaCached, - getPhotosNearIdCached, -} from '@/photo/cache'; - -const getPhotosNearIdCachedCached = cache(( - photoId: string, - simulation: FilmSimulation, -) => - getPhotosNearIdCached( - photoId, - { simulation, limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 }, - )); - -interface PhotoFilmSimulationProps { - params: Promise<{ photoId: string, simulation: FilmSimulation }> -} - -export async function generateMetadata({ - params, -}: PhotoFilmSimulationProps): Promise { - const { photoId, simulation } = await params; - - const { photo } = await getPhotosNearIdCachedCached(photoId, simulation); - - if (!photo) { return {}; } - - const title = titleForPhoto(photo); - const description = descriptionForPhoto(photo); - const images = absolutePathForPhotoImage(photo); - const url = absolutePathForPhoto({ photo, simulation }); - - return { - title, - description, - openGraph: { - title, - images, - description, - url, - }, - twitter: { - title, - description, - images, - card: 'summary_large_image', - }, - }; -} - -export default async function PhotoFilmSimulationPage({ - params, - children, -}: PhotoFilmSimulationProps & { children: ReactNode }) { - const { photoId, simulation } = await params; - - const { photo, photos, photosGrid, indexNumber } = - await getPhotosNearIdCachedCached(photoId, simulation); - - if (!photo) { redirect(PATH_ROOT); } - - const { count, dateRange } = await getPhotosMetaCached({ simulation }); - - return <> - {children} - - ; -} diff --git a/src/app/film/[simulation]/[photoId]/page.tsx b/src/app/film/[simulation]/[photoId]/page.tsx index 67e08591..aaee4411 100644 --- a/src/app/film/[simulation]/[photoId]/page.tsx +++ b/src/app/film/[simulation]/[photoId]/page.tsx @@ -1,3 +1,89 @@ -export default function Page() { - return null; +import { + RELATED_GRID_PHOTOS_TO_SHOW, + descriptionForPhoto, + titleForPhoto, +} from '@/photo'; +import { Metadata } from 'next/types'; +import { redirect } from 'next/navigation'; +import { + PATH_ROOT, + absolutePathForPhoto, + absolutePathForPhotoImage, +} from '@/site/paths'; +import PhotoDetailPage from '@/photo/PhotoDetailPage'; +import { FilmSimulation } from '@/simulation'; +import { + getPhotosMetaCached, + getPhotosNearIdCached, +} from '@/photo/cache'; +import { cache } from 'react'; + +const getPhotosNearIdCachedCached = cache(( + photoId: string, + simulation: FilmSimulation, +) => + getPhotosNearIdCached( + photoId, + { simulation, limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 }, + )); + +interface PhotoFilmSimulationProps { + params: Promise<{ photoId: string, simulation: FilmSimulation }> +} + +export async function generateMetadata({ + params, +}: PhotoFilmSimulationProps): Promise { + const { photoId, simulation } = await params; + + const { photo } = await getPhotosNearIdCachedCached(photoId, simulation); + + if (!photo) { return {}; } + + const title = titleForPhoto(photo); + const description = descriptionForPhoto(photo); + const images = absolutePathForPhotoImage(photo); + const url = absolutePathForPhoto({ photo, simulation }); + + return { + title, + description, + openGraph: { + title, + images, + description, + url, + }, + twitter: { + title, + description, + images, + card: 'summary_large_image', + }, + }; +} + +export default async function PhotoFilmSimulationPage({ + params, +}: PhotoFilmSimulationProps) { + const { photoId, simulation } = await params; + + const { photo, photos, photosGrid, indexNumber } = + await getPhotosNearIdCachedCached(photoId, simulation); + + if (!photo) { redirect(PATH_ROOT); } + + const { count, dateRange } = await getPhotosMetaCached({ simulation }); + + return ( + + ); } diff --git a/src/app/film/[simulation]/[photoId]/share/page.tsx b/src/app/film/[simulation]/[photoId]/share/page.tsx deleted file mode 100644 index 0553f1d1..00000000 --- a/src/app/film/[simulation]/[photoId]/share/page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { getPhotoCached } from '@/photo/cache'; -import PhotoShareModal from '@/photo/PhotoShareModal'; -import { FilmSimulation } from '@/simulation'; -import { PATH_ROOT } from '@/site/paths'; -import { redirect } from 'next/navigation'; - -export default async function Share({ - params, -}: { - params: Promise<{ photoId: string, simulation: FilmSimulation }> -}) { - const { photoId, simulation } = await params; - - const photo = await getPhotoCached(photoId); - - if (!photo) { return redirect(PATH_ROOT); } - - return ; -} diff --git a/src/app/film/[simulation]/share/page.tsx b/src/app/film/[simulation]/share/page.tsx deleted file mode 100644 index 3439bd22..00000000 --- a/src/app/film/[simulation]/share/page.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo'; -import { FilmSimulation, generateMetaForFilmSimulation } from '@/simulation'; -import FilmSimulationOverview from '@/simulation/FilmSimulationOverview'; -import FilmSimulationShareModal from '@/simulation/FilmSimulationShareModal'; -import { getPhotosFilmSimulationDataCached } from '@/simulation/data'; -import { Metadata } from 'next/types'; -import { cache } from 'react'; - -const getPhotosFilmSimulationDataCachedCached = - cache((simulation: FilmSimulation) => getPhotosFilmSimulationDataCached({ - simulation, - limit: INFINITE_SCROLL_GRID_INITIAL, - })); - -interface FilmSimulationProps { - params: Promise<{ simulation: FilmSimulation }> -} - -export async function generateMetadata({ - params, -}: FilmSimulationProps): Promise { - const { simulation } = await params; - - const [ - photos, - { count, dateRange }, - ] = await getPhotosFilmSimulationDataCachedCached(simulation); - - const { - url, - title, - description, - images, - } = generateMetaForFilmSimulation(simulation, photos, count, dateRange); - - return { - title, - openGraph: { - title, - description, - images, - url, - }, - twitter: { - images, - description, - card: 'summary_large_image', - }, - description, - }; -} - -export default async function Share({ - params, -}: FilmSimulationProps) { - const { simulation } = await params; - - const [ - photos, - { count, dateRange }, - ] = await getPhotosFilmSimulationDataCachedCached(simulation); - - return <> - - - ; -} diff --git a/src/app/focal/[focal]/[photoId]/layout.tsx b/src/app/focal/[focal]/[photoId]/layout.tsx deleted file mode 100644 index 4c631c69..00000000 --- a/src/app/focal/[focal]/[photoId]/layout.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { - RELATED_GRID_PHOTOS_TO_SHOW, - descriptionForPhoto, - titleForPhoto, -} from '@/photo'; -import { Metadata } from 'next/types'; -import { redirect } from 'next/navigation'; -import { - PATH_ROOT, - absolutePathForPhoto, - absolutePathForPhotoImage, -} from '@/site/paths'; -import PhotoDetailPage from '@/photo/PhotoDetailPage'; -import { getPhotosNearIdCached } from '@/photo/cache'; -import { ReactNode, cache } from 'react'; -import { getPhotosMeta } from '@/photo/db/query'; -import { getFocalLengthFromString } from '@/focal'; - -const getPhotosNearIdCachedCached = cache((photoId: string, focal: number) => - getPhotosNearIdCached( - photoId, - { focal, limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 }, - )); - -interface PhotoFocalLengthProps { - params: Promise<{ photoId: string, focal: string }> -} - -export async function generateMetadata({ - params, -}: PhotoFocalLengthProps): Promise { - const { photoId, focal: focalString } = await params; - - const focal = getFocalLengthFromString(focalString); - - const { photo } = await getPhotosNearIdCachedCached(photoId, focal); - - if (!photo) { return {}; } - - const title = titleForPhoto(photo); - const description = descriptionForPhoto(photo); - const images = absolutePathForPhotoImage(photo); - const url = absolutePathForPhoto({ photo, focal }); - - return { - title, - description, - openGraph: { - title, - images, - description, - url, - }, - twitter: { - title, - description, - images, - card: 'summary_large_image', - }, - }; -} - -export default async function PhotoFocalLengthPage({ - params, - children, -}: PhotoFocalLengthProps & { children: ReactNode }) { - const { photoId, focal: focalString } = await params; - - const focal = getFocalLengthFromString(focalString); - - const { photo, photos, photosGrid, indexNumber } = - await getPhotosNearIdCachedCached(photoId, focal); - - if (!photo) { redirect(PATH_ROOT); } - - const { count, dateRange } = await getPhotosMeta({ focal }); - - return <> - {children} - - ; -} diff --git a/src/app/focal/[focal]/[photoId]/page.tsx b/src/app/focal/[focal]/[photoId]/page.tsx index 67e08591..1ca40aa1 100644 --- a/src/app/focal/[focal]/[photoId]/page.tsx +++ b/src/app/focal/[focal]/[photoId]/page.tsx @@ -1,3 +1,88 @@ -export default function Page() { - return null; +import { + RELATED_GRID_PHOTOS_TO_SHOW, + descriptionForPhoto, + titleForPhoto, +} from '@/photo'; +import { Metadata } from 'next/types'; +import { redirect } from 'next/navigation'; +import { + PATH_ROOT, + absolutePathForPhoto, + absolutePathForPhotoImage, +} from '@/site/paths'; +import PhotoDetailPage from '@/photo/PhotoDetailPage'; +import { getPhotosNearIdCached } from '@/photo/cache'; +import { cache } from 'react'; +import { getPhotosMeta } from '@/photo/db/query'; +import { getFocalLengthFromString } from '@/focal'; + +const getPhotosNearIdCachedCached = cache((photoId: string, focal: number) => + getPhotosNearIdCached( + photoId, + { focal, limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 }, + )); + +interface PhotoFocalLengthProps { + params: Promise<{ photoId: string, focal: string }> +} + +export async function generateMetadata({ + params, +}: PhotoFocalLengthProps): Promise { + const { photoId, focal: focalString } = await params; + + const focal = getFocalLengthFromString(focalString); + + const { photo } = await getPhotosNearIdCachedCached(photoId, focal); + + if (!photo) { return {}; } + + const title = titleForPhoto(photo); + const description = descriptionForPhoto(photo); + const images = absolutePathForPhotoImage(photo); + const url = absolutePathForPhoto({ photo, focal }); + + return { + title, + description, + openGraph: { + title, + images, + description, + url, + }, + twitter: { + title, + description, + images, + card: 'summary_large_image', + }, + }; +} + +export default async function PhotoFocalLengthPage({ + params, +}: PhotoFocalLengthProps) { + const { photoId, focal: focalString } = await params; + + const focal = getFocalLengthFromString(focalString); + + const { photo, photos, photosGrid, indexNumber } = + await getPhotosNearIdCachedCached(photoId, focal); + + if (!photo) { redirect(PATH_ROOT); } + + const { count, dateRange } = await getPhotosMeta({ focal }); + + return ( + + ); } diff --git a/src/app/focal/[focal]/[photoId]/share/page.tsx b/src/app/focal/[focal]/[photoId]/share/page.tsx deleted file mode 100644 index 00d02a84..00000000 --- a/src/app/focal/[focal]/[photoId]/share/page.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { getFocalLengthFromString } from '@/focal'; -import { getPhotoCached } from '@/photo/cache'; -import PhotoShareModal from '@/photo/PhotoShareModal'; -import { PATH_ROOT } from '@/site/paths'; -import { redirect } from 'next/navigation'; - -export default async function Share({ - params, -}: { - params: Promise<{ photoId: string, focal: string }> -}) { - const { photoId, focal: focalString } = await params; - - const focal = getFocalLengthFromString(focalString); - - const photo = await getPhotoCached(photoId); - - if (!photo) { return redirect(PATH_ROOT); } - - return ; -} diff --git a/src/app/focal/[focal]/share/page.tsx b/src/app/focal/[focal]/share/page.tsx deleted file mode 100644 index fcf468ea..00000000 --- a/src/app/focal/[focal]/share/page.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { generateMetaForFocalLength, getFocalLengthFromString } from '@/focal'; -import FocalLengthOverview from '@/focal/FocalLengthOverview'; -import FocalLengthShareModal from '@/focal/FocalLengthShareModal'; -import { getPhotosFocalLengthDataCached } from '@/focal/data'; -import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo'; -import type { Metadata } from 'next'; -import { cache } from 'react'; - -const getPhotosFocalLengthDataCachedCached = cache((focal: number) => - getPhotosFocalLengthDataCached({ - focal, - limit: INFINITE_SCROLL_GRID_INITIAL, - })); - -interface FocalLengthProps { - params: Promise<{ focal: string }> -} - -export async function generateMetadata({ - params, -}: FocalLengthProps): Promise { - const { focal: focalString } = await params; - - const focal = getFocalLengthFromString(focalString); - - const [ - photos, - { count, dateRange }, - ] = await getPhotosFocalLengthDataCachedCached(focal); - - const { - url, - title, - description, - images, - } = generateMetaForFocalLength(focal, photos, count, dateRange); - - return { - title, - openGraph: { - title, - description, - images, - url, - }, - twitter: { - images, - description, - card: 'summary_large_image', - }, - description, - }; -} - -export default async function Share({ - params, -}: FocalLengthProps) { - const { focal: focalString } = await params; - - const focal = getFocalLengthFromString(focalString); - - const [ - photos, - { count, dateRange }, - ] = await getPhotosFocalLengthDataCachedCached(focal); - - return <> - - - ; -} diff --git a/src/app/p/[photoId]/layout.tsx b/src/app/p/[photoId]/layout.tsx deleted file mode 100644 index 0d57a162..00000000 --- a/src/app/p/[photoId]/layout.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { - RELATED_GRID_PHOTOS_TO_SHOW, - descriptionForPhoto, - titleForPhoto, -} from '@/photo'; -import { Metadata } from 'next/types'; -import { redirect } from 'next/navigation'; -import { - PATH_ROOT, - absolutePathForPhoto, - absolutePathForPhotoImage, -} from '@/site/paths'; -import PhotoDetailPage from '@/photo/PhotoDetailPage'; -import { getPhotosNearIdCached } from '@/photo/cache'; -import { IS_PRODUCTION, STATICALLY_OPTIMIZED_PAGES } from '@/site/config'; -import { getPhotoIds } from '@/photo/db/query'; -import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; -import { ReactNode, cache } from 'react'; - -export const maxDuration = 60; - -const getPhotosNearIdCachedCached = cache((photoId: string) => - getPhotosNearIdCached(photoId, { limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 })); - -export let generateStaticParams: - (() => Promise<{ photoId: string }[]>) | undefined = undefined; - -if (STATICALLY_OPTIMIZED_PAGES && IS_PRODUCTION) { - generateStaticParams = async () => { - const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT }); - return photos.map(photoId => ({ photoId })); - }; -} - -interface PhotoProps { - params: Promise<{ photoId: string }> -} - -export async function generateMetadata({ - params, -}:PhotoProps): Promise { - const { photoId } = await params; - const { photo } = await getPhotosNearIdCachedCached(photoId); - - if (!photo) { return {}; } - - const title = titleForPhoto(photo); - const description = descriptionForPhoto(photo); - const images = absolutePathForPhotoImage(photo); - const url = absolutePathForPhoto({ photo }); - - return { - title, - description, - openGraph: { - title, - images, - description, - url, - }, - twitter: { - title, - description, - images, - card: 'summary_large_image', - }, - }; -} - -export default async function PhotoPage({ - params, - children, -}: PhotoProps & { children: ReactNode }) { - const { photoId } = await params; - const { photo, photos, photosGrid } = - await getPhotosNearIdCachedCached(photoId); - - if (!photo) { redirect(PATH_ROOT); } - - return <> - {children} - - ; -} diff --git a/src/app/p/[photoId]/page.tsx b/src/app/p/[photoId]/page.tsx index 67e08591..decfb273 100644 --- a/src/app/p/[photoId]/page.tsx +++ b/src/app/p/[photoId]/page.tsx @@ -1,3 +1,82 @@ -export default function Page() { - return null; +import { + RELATED_GRID_PHOTOS_TO_SHOW, + descriptionForPhoto, + titleForPhoto, +} from '@/photo'; +import { Metadata } from 'next/types'; +import { redirect } from 'next/navigation'; +import { + PATH_ROOT, + absolutePathForPhoto, + absolutePathForPhotoImage, +} from '@/site/paths'; +import PhotoDetailPage from '@/photo/PhotoDetailPage'; +import { getPhotosNearIdCached } from '@/photo/cache'; +import { IS_PRODUCTION, STATICALLY_OPTIMIZED_PAGES } from '@/site/config'; +import { getPhotoIds } from '@/photo/db/query'; +import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; +import { cache } from 'react'; + +export const maxDuration = 60; + +const getPhotosNearIdCachedCached = cache((photoId: string) => + getPhotosNearIdCached(photoId, { limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 })); + +export let generateStaticParams: + (() => Promise<{ photoId: string }[]>) | undefined = undefined; + +if (STATICALLY_OPTIMIZED_PAGES && IS_PRODUCTION) { + generateStaticParams = async () => { + const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT }); + return photos.map(photoId => ({ photoId })); + }; +} + +interface PhotoProps { + params: Promise<{ photoId: string }> +} + +export async function generateMetadata({ + params, +}:PhotoProps): Promise { + const { photoId } = await params; + const { photo } = await getPhotosNearIdCachedCached(photoId); + + if (!photo) { return {}; } + + const title = titleForPhoto(photo); + const description = descriptionForPhoto(photo); + const images = absolutePathForPhotoImage(photo); + const url = absolutePathForPhoto({ photo }); + + return { + title, + description, + openGraph: { + title, + images, + description, + url, + }, + twitter: { + title, + description, + images, + card: 'summary_large_image', + }, + }; +} + +export default async function PhotoPage({ + params, +}: PhotoProps) { + const { photoId } = await params; + const { photo, photos, photosGrid } = + await getPhotosNearIdCachedCached(photoId); + + if (!photo) { redirect(PATH_ROOT); } + + return ( + + ); } diff --git a/src/app/p/[photoId]/share/page.tsx b/src/app/p/[photoId]/share/page.tsx deleted file mode 100644 index 104aa74e..00000000 --- a/src/app/p/[photoId]/share/page.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { getPhotoCached } from '@/photo/cache'; -import PhotoShareModal from '@/photo/PhotoShareModal'; -import { PATH_ROOT } from '@/site/paths'; -import { redirect } from 'next/navigation'; - -export default async function Share({ - params, -}: { - params: Promise<{ photoId: string }> -}) { - const { photoId } = await params; - - const photo = await getPhotoCached(photoId); - - if (!photo) { return redirect(PATH_ROOT); } - - return ; -} diff --git a/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx b/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx deleted file mode 100644 index d2f0a58d..00000000 --- a/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import { - RELATED_GRID_PHOTOS_TO_SHOW, - descriptionForPhoto, - titleForPhoto, -} from '@/photo'; -import { Metadata } from 'next/types'; -import { redirect } from 'next/navigation'; -import { - PATH_ROOT, - absolutePathForPhoto, - absolutePathForPhotoImage, -} from '@/site/paths'; -import PhotoDetailPage from '@/photo/PhotoDetailPage'; -import { - getPhotosMetaCached, - getPhotosNearIdCached, -} from '@/photo/cache'; -import { - PhotoCameraProps, - cameraFromPhoto, - getCameraFromParams, -} from '@/camera'; -import { ReactNode, cache } from 'react'; - -const getPhotosNearIdCachedCached = cache(( - photoId: string, - make: string, - model: string, -) => - getPhotosNearIdCached( - photoId, { - camera: getCameraFromParams({ make, model }), - limit: RELATED_GRID_PHOTOS_TO_SHOW + 2, - }, - )); - -export async function generateMetadata({ - params, -}: PhotoCameraProps): Promise { - const { photoId, make, model } = await params; - - const { photo } = await getPhotosNearIdCachedCached(photoId, make, model); - - if (!photo) { return {}; } - - const title = titleForPhoto(photo); - const description = descriptionForPhoto(photo); - const images = absolutePathForPhotoImage(photo); - const url = absolutePathForPhoto({ - photo, - camera: cameraFromPhoto(photo, { make, model }), - }); - - return { - title, - description, - openGraph: { - title, - images, - description, - url, - }, - twitter: { - title, - description, - images, - card: 'summary_large_image', - }, - }; -} - -export default async function PhotoCameraPage({ - params, - children, -}: PhotoCameraProps & { children: ReactNode }) { - const { photoId, make, model } = await params; - - const { photo, photos, photosGrid, indexNumber } = - await getPhotosNearIdCachedCached(photoId, make, model); - - if (!photo) { redirect(PATH_ROOT); } - - const camera = cameraFromPhoto(photo, { make, model }); - - const { count, dateRange } = await getPhotosMetaCached({ camera }); - - return <> - {children} - - ; -} diff --git a/src/app/shot-on/[make]/[model]/[photoId]/page.tsx b/src/app/shot-on/[make]/[model]/[photoId]/page.tsx index 67e08591..74972892 100644 --- a/src/app/shot-on/[make]/[model]/[photoId]/page.tsx +++ b/src/app/shot-on/[make]/[model]/[photoId]/page.tsx @@ -1,3 +1,97 @@ -export default function Page() { - return null; +import { + RELATED_GRID_PHOTOS_TO_SHOW, + descriptionForPhoto, + titleForPhoto, +} from '@/photo'; +import { Metadata } from 'next/types'; +import { redirect } from 'next/navigation'; +import { + PATH_ROOT, + absolutePathForPhoto, + absolutePathForPhotoImage, +} from '@/site/paths'; +import PhotoDetailPage from '@/photo/PhotoDetailPage'; +import { + getPhotosMetaCached, + getPhotosNearIdCached, +} from '@/photo/cache'; +import { + PhotoCameraProps, + cameraFromPhoto, + getCameraFromParams, +} from '@/camera'; +import { cache } from 'react'; + +const getPhotosNearIdCachedCached = cache(( + photoId: string, + make: string, + model: string, +) => + getPhotosNearIdCached( + photoId, { + camera: getCameraFromParams({ make, model }), + limit: RELATED_GRID_PHOTOS_TO_SHOW + 2, + }, + )); + +export async function generateMetadata({ + params, +}: PhotoCameraProps): Promise { + const { photoId, make, model } = await params; + + const { photo } = await getPhotosNearIdCachedCached(photoId, make, model); + + if (!photo) { return {}; } + + const title = titleForPhoto(photo); + const description = descriptionForPhoto(photo); + const images = absolutePathForPhotoImage(photo); + const url = absolutePathForPhoto({ + photo, + camera: cameraFromPhoto(photo, { make, model }), + }); + + return { + title, + description, + openGraph: { + title, + images, + description, + url, + }, + twitter: { + title, + description, + images, + card: 'summary_large_image', + }, + }; +} + +export default async function PhotoCameraPage({ + params, +}: PhotoCameraProps) { + const { photoId, make, model } = await params; + + const { photo, photos, photosGrid, indexNumber } = + await getPhotosNearIdCachedCached(photoId, make, model); + + if (!photo) { redirect(PATH_ROOT); } + + const camera = cameraFromPhoto(photo, { make, model }); + + const { count, dateRange } = await getPhotosMetaCached({ camera }); + + return ( + + ); } diff --git a/src/app/shot-on/[make]/[model]/[photoId]/share/page.tsx b/src/app/shot-on/[make]/[model]/[photoId]/share/page.tsx deleted file mode 100644 index 9bd6dd89..00000000 --- a/src/app/shot-on/[make]/[model]/[photoId]/share/page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { getPhotoCached } from '@/photo/cache'; -import { PhotoCameraProps, cameraFromPhoto } from '@/camera'; -import PhotoShareModal from '@/photo/PhotoShareModal'; -import { PATH_ROOT } from '@/site/paths'; -import { redirect } from 'next/navigation'; - -export default async function Share({ - params, -}: PhotoCameraProps) { - const { photoId, make, model } = await params; - - const photo = await getPhotoCached(photoId); - - if (!photo) { return redirect(PATH_ROOT); } - - const camera = cameraFromPhoto(photo, { make, model }); - - return ; -} diff --git a/src/app/shot-on/[make]/[model]/share/page.tsx b/src/app/shot-on/[make]/[model]/share/page.tsx deleted file mode 100644 index 760a3c66..00000000 --- a/src/app/shot-on/[make]/[model]/share/page.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { CameraProps } from '@/camera'; -import CameraShareModal from '@/camera/CameraShareModal'; -import { generateMetaForCamera } from '@/camera/meta'; -import { Metadata } from 'next/types'; -import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo'; -import { getPhotosCameraDataCached } from '@/camera/data'; -import CameraOverview from '@/camera/CameraOverview'; -import { cache } from 'react'; - -const getPhotosCameraDataCachedCached = cache(( - make: string, - model: string, -) => getPhotosCameraDataCached( - make, - model, - INFINITE_SCROLL_GRID_INITIAL, -)); - -export async function generateMetadata({ - params, -}: CameraProps): Promise { - const { make, model } = await params; - - const [ - photos, - { count, dateRange }, - camera, - ] = await getPhotosCameraDataCachedCached(make, model); - - const { - url, - title, - description, - images, - } = generateMetaForCamera(camera, photos, count, dateRange); - - return { - title, - openGraph: { - title, - description, - images, - url, - }, - twitter: { - images, - description, - card: 'summary_large_image', - }, - description, - }; -} - -export default async function Share({ params }: CameraProps) { - const { make, model } = await params; - - const [ - photos, - { count, dateRange }, - camera, - ] = await getPhotosCameraDataCachedCached(make, model); - - return <> - - - ; -} diff --git a/src/app/tag/[tag]/[photoId]/layout.tsx b/src/app/tag/[tag]/[photoId]/layout.tsx deleted file mode 100644 index a28f7d7d..00000000 --- a/src/app/tag/[tag]/[photoId]/layout.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { - RELATED_GRID_PHOTOS_TO_SHOW, - descriptionForPhoto, - titleForPhoto, -} from '@/photo'; -import { Metadata } from 'next/types'; -import { redirect } from 'next/navigation'; -import { - PATH_ROOT, - absolutePathForPhoto, - absolutePathForPhotoImage, -} from '@/site/paths'; -import PhotoDetailPage from '@/photo/PhotoDetailPage'; -import { getPhotosNearIdCached } from '@/photo/cache'; -import { ReactNode, cache } from 'react'; -import { getPhotosMeta } from '@/photo/db/query'; - -const getPhotosNearIdCachedCached = cache((photoId: string, tag: string) => - getPhotosNearIdCached( - photoId, - { tag, limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 }, - )); - -interface PhotoTagProps { - params: Promise<{ photoId: string, tag: string }> -} - -export async function generateMetadata({ - params, -}: PhotoTagProps): Promise { - const { photoId, tag } = await params; - - const { photo } = await getPhotosNearIdCachedCached(photoId, tag); - - if (!photo) { return {}; } - - const title = titleForPhoto(photo); - const description = descriptionForPhoto(photo); - const images = absolutePathForPhotoImage(photo); - const url = absolutePathForPhoto({ photo, tag }); - - return { - title, - description, - openGraph: { - title, - images, - description, - url, - }, - twitter: { - title, - description, - images, - card: 'summary_large_image', - }, - }; -} - -export default async function PhotoTagPage({ - params, - children, -}: PhotoTagProps & { children: ReactNode }) { - const { photoId, tag } = await params; - const { photo, photos, photosGrid, indexNumber } = - await getPhotosNearIdCachedCached(photoId, tag); - - if (!photo) { redirect(PATH_ROOT); } - - const { count, dateRange } = await getPhotosMeta({ tag }); - - return <> - {children} - - ; -} diff --git a/src/app/tag/[tag]/[photoId]/page.tsx b/src/app/tag/[tag]/[photoId]/page.tsx index 67e08591..98c27fd0 100644 --- a/src/app/tag/[tag]/[photoId]/page.tsx +++ b/src/app/tag/[tag]/[photoId]/page.tsx @@ -1,3 +1,82 @@ -export default function Page() { - return null; +import { + RELATED_GRID_PHOTOS_TO_SHOW, + descriptionForPhoto, + titleForPhoto, +} from '@/photo'; +import { Metadata } from 'next/types'; +import { redirect } from 'next/navigation'; +import { + PATH_ROOT, + absolutePathForPhoto, + absolutePathForPhotoImage, +} from '@/site/paths'; +import PhotoDetailPage from '@/photo/PhotoDetailPage'; +import { getPhotosNearIdCached } from '@/photo/cache'; +import { cache } from 'react'; +import { getPhotosMeta } from '@/photo/db/query'; + +const getPhotosNearIdCachedCached = cache((photoId: string, tag: string) => + getPhotosNearIdCached( + photoId, + { tag, limit: RELATED_GRID_PHOTOS_TO_SHOW + 2 }, + )); + +interface PhotoTagProps { + params: Promise<{ photoId: string, tag: string }> +} + +export async function generateMetadata({ + params, +}: PhotoTagProps): Promise { + const { photoId, tag } = await params; + + const { photo } = await getPhotosNearIdCachedCached(photoId, tag); + + if (!photo) { return {}; } + + const title = titleForPhoto(photo); + const description = descriptionForPhoto(photo); + const images = absolutePathForPhotoImage(photo); + const url = absolutePathForPhoto({ photo, tag }); + + return { + title, + description, + openGraph: { + title, + images, + description, + url, + }, + twitter: { + title, + description, + images, + card: 'summary_large_image', + }, + }; +} + +export default async function PhotoTagPage({ + params, +}: PhotoTagProps) { + const { photoId, tag } = await params; + const { photo, photos, photosGrid, indexNumber } = + await getPhotosNearIdCachedCached(photoId, tag); + + if (!photo) { redirect(PATH_ROOT); } + + const { count, dateRange } = await getPhotosMeta({ tag }); + + return ( + + ); } diff --git a/src/app/tag/[tag]/[photoId]/share/page.tsx b/src/app/tag/[tag]/[photoId]/share/page.tsx deleted file mode 100644 index ceb5bfef..00000000 --- a/src/app/tag/[tag]/[photoId]/share/page.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { getPhotoCached } from '@/photo/cache'; -import PhotoShareModal from '@/photo/PhotoShareModal'; -import { PATH_ROOT } from '@/site/paths'; -import { redirect } from 'next/navigation'; - -export default async function Share({ - params, -}: { - params: Promise<{ photoId: string, tag: string }> -}) { - const { photoId, tag } = await params; - - const photo = await getPhotoCached(photoId); - - if (!photo) { return redirect(PATH_ROOT); } - - return ; -} diff --git a/src/app/tag/[tag]/share/page.tsx b/src/app/tag/[tag]/share/page.tsx deleted file mode 100644 index ca73dc93..00000000 --- a/src/app/tag/[tag]/share/page.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo'; -import { generateMetaForTag } from '@/tag'; -import TagOverview from '@/tag/TagOverview'; -import TagShareModal from '@/tag/TagShareModal'; -import { getPhotosTagDataCached } from '@/tag/data'; -import type { Metadata } from 'next'; -import { cache } from 'react'; - -const getPhotosTagDataCachedCached = cache((tag: string) => - getPhotosTagDataCached({ tag, limit: INFINITE_SCROLL_GRID_INITIAL })); - -interface TagProps { - params: Promise<{ tag: string }> -} - -export async function generateMetadata({ - params, -}: TagProps): Promise { - const { tag: tagFromParams } = await params; - - const tag = decodeURIComponent(tagFromParams); - - const [ - photos, - { count, dateRange }, - ] = await getPhotosTagDataCachedCached(tag); - - const { - url, - title, - description, - images, - } = generateMetaForTag(tag, photos, count, dateRange); - - return { - title, - openGraph: { - title, - description, - images, - url, - }, - twitter: { - images, - description, - card: 'summary_large_image', - }, - description, - }; -} - -export default async function Share({ - params, -}: TagProps) { - const { tag: tagFromParams } = await params; - - const tag = decodeURIComponent(tagFromParams); - - const [ - photos, - { count, dateRange }, - ] = await getPhotosTagDataCachedCached(tag); - - return <> - - - ; -}