Use next/react cache on camera/photo page

This commit is contained in:
Sam Becker 2024-03-03 23:38:54 -06:00
parent 28c5a5ac53
commit 464239746e
2 changed files with 7 additions and 4 deletions

View File

@ -15,9 +15,9 @@ import NavClient from '@/site/NavClient';
import { Metadata } from 'next/types';
import MoreComponentsProvider from '@/state/MoreComponentsProvider';
import CommandK from '@/site/CommandK';
import CommandKClient from '@/components/CommandKClient';
import '../site/globals.css';
import CommandKClient from '@/components/CommandKClient';
const ibmPlexMono = IBM_Plex_Mono({
subsets: ['latin'],

View File

@ -13,7 +13,10 @@ import PhotoDetailPage from '@/photo/PhotoDetailPage';
import { getPhotoCached } from '@/photo/cache';
import { cameraFromPhoto } from '@/camera';
import { getPhotosCameraDataCached } from '@/camera/data';
import { ReactNode } from 'react';
import { ReactNode, cache } from 'react';
const getPhotoCachedCached =
cache((photoId: string) => getPhotoCached(photoId));
interface PhotoCameraProps {
params: { photoId: string, camera: string }
@ -22,7 +25,7 @@ interface PhotoCameraProps {
export async function generateMetadata({
params: { photoId, camera },
}: PhotoCameraProps): Promise<Metadata> {
const photo = await getPhotoCached(photoId);
const photo = await getPhotoCachedCached(photoId);
if (!photo) { return {}; }
@ -57,7 +60,7 @@ export default async function PhotoCameraPage({
params: { photoId, camera: cameraProp },
children,
}: PhotoCameraProps & { children: ReactNode }) {
const photo = await getPhotoCached(photoId);
const photo = await getPhotoCachedCached(photoId);
if (!photo) { redirect(PATH_ROOT); }