import { getPhotosCached, getPhotosCountCached } from '@/cache'; import AnimateItems from '@/components/AnimateItems'; import MorePhotos from '@/photo/MorePhotos'; import SiteGrid from '@/components/SiteGrid'; import { generateOgImageMetaForPhotos } from '@/photo'; import PhotoLarge from '@/photo/PhotoLarge'; import PhotosEmptyState from '@/photo/PhotosEmptyState'; import { PaginationParams, getPaginationForSearchParams, } from '@/site/pagination'; import { pathForRoot } from '@/site/paths'; import { Metadata } from 'next'; import { MAX_PHOTOS_TO_SHOW_OG } from '@/photo/image-response'; export const runtime = 'edge'; export async function generateMetadata(): Promise { // Make homepage queries resilient to error on first time setup const photos = await getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }) .catch(() => []); return generateOgImageMetaForPhotos(photos); } export default async function HomePage({ searchParams }: PaginationParams) { const { offset, limit } = getPaginationForSearchParams(searchParams, 12); const [ photos, count, ] = await Promise.all([ // Make homepage queries resilient to error on first time setup getPhotosCached({ limit }).catch(() => []), getPhotosCountCached().catch(() => 0), ]); const showMorePhotos = count > photos.length; return ( photos.length > 0 ?
)} /> {showMorePhotos && } />}
: ); }