Merge branch 'main' into ppr-static

This commit is contained in:
Sam Becker 2024-04-29 23:18:17 -05:00
commit 03169e71f6
10 changed files with 71 additions and 16 deletions

View File

@ -26,7 +26,7 @@ export default async function AdminNav() {
return 0;
}),
getUniqueTagsCached().then(tags => tags.length).catch(() => 0),
getPhotosMostRecentUpdateCached(),
getPhotosMostRecentUpdateCached().catch(() => undefined),
]);
const navItemPhotos = {

View File

@ -26,9 +26,11 @@ export default async function AdminPhotosPage() {
includeHidden: true,
sortBy: 'createdAt',
limit: INFINITE_SCROLL_INITIAL_ADMIN_PHOTOS,
}),
getPhotosCountIncludingHiddenCached(),
DEBUG_PHOTO_BLOBS ? getStoragePhotoUrlsNoStore() : [],
}).catch(() => []),
getPhotosCountIncludingHiddenCached().catch(() => 0),
DEBUG_PHOTO_BLOBS
? getStoragePhotoUrlsNoStore()
: [],
]);
return (

View File

@ -3,7 +3,7 @@ import SiteGrid from '@/components/SiteGrid';
import { getUniqueTagsHiddenCached } from '@/photo/cache';
export default async function AdminTagsPage() {
const tags = await getUniqueTagsHiddenCached();
const tags = await getUniqueTagsHiddenCached().catch(() => []);
return (
<SiteGrid

View File

@ -19,7 +19,10 @@ export const dynamic = 'force-static';
const getPhotosCached = cache(getPhotos);
export async function generateMetadata(): Promise<Metadata> {
const photos = await getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG });
const photos = await getPhotosCached({
limit: MAX_PHOTOS_TO_SHOW_OG,
})
.catch(() => []);
return generateOgImageMetaForPhotos(photos);
}
@ -31,7 +34,7 @@ export default async function GridPage() {
cameras,
simulations,
] = await Promise.all([
getPhotosCached({ limit: INFINITE_SCROLL_INITIAL_GRID }),
getPhotosCached({ limit: INFINITE_SCROLL_INITIAL_GRID }).catch(() => []),
...getPhotoSidebarData(),
]);

View File

@ -9,13 +9,15 @@ import { ImageResponse } from 'next/og';
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
import { isNextImageReadyBasedOnPhotos } from '@/photo';
export const dynamic = 'force-static';
export async function GET() {
const [
photos,
headers,
{ fontFamily, fonts },
] = await Promise.all([
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }),
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }).catch(() => []),
getImageResponseCacheControlHeaders(),
getIBMPlexMonoMedium(),
]);

45
src/app/not-found.tsx Normal file
View File

@ -0,0 +1,45 @@
'use client';
import SiteGrid from '@/components/SiteGrid';
import { PATH_ROOT } from '@/site/paths';
import { clsx } from 'clsx/lite';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
export default function NotFound() {
const pathname = usePathname();
return (
<SiteGrid contentMain={
<div className={clsx(
'min-h-72 sm:min-h-96',
'flex flex-col items-center justify-center gap-3',
)}>
<h1 className={clsx(
'text-[100px] sm:text-[120px] leading-none',
'text-gray-800 dark:text-gray-200',
)}>
404
</h1>
<div className="flex flex-col gap-6 text-center text-dim">
<div>
<span className={clsx(
'underline underline-offset-2 decoration-dotted',
'cursor-not-allowed',
)}>
{pathname}
</span>
{' '}
could not be found
</div>
<Link
href={PATH_ROOT}
className="text-main"
>
Return Home
</Link>
</div>
</div>
} />
);
}

View File

@ -16,7 +16,6 @@ export const dynamic = 'force-static';
const getPhotosCached = cache(getPhotos);
export async function generateMetadata(): Promise<Metadata> {
// Make homepage queries resilient to error on first time setup
const photos = await getPhotosCached({
limit: MAX_PHOTOS_TO_SHOW_OG,
})
@ -25,7 +24,6 @@ export async function generateMetadata(): Promise<Metadata> {
}
export default async function HomePage() {
// Make homepage queries resilient to error on first time setup
const [
photos,
photosCount,

View File

@ -19,7 +19,7 @@ export async function GET() {
getPhotosCached({
sortBy: 'priority',
limit: MAX_PHOTOS_TO_SHOW_TEMPLATE_TIGHT,
}),
}).catch(() => []),
getIBMPlexMonoMedium(),
getImageResponseCacheControlHeaders(),
]);

View File

@ -16,7 +16,10 @@ export async function GET() {
{ fontFamily, fonts },
headers,
] = await Promise.all([
getPhotosCached({ sortBy: 'priority', limit: MAX_PHOTOS_TO_SHOW_TEMPLATE }),
getPhotosCached({
sortBy: 'priority',
limit: MAX_PHOTOS_TO_SHOW_TEMPLATE,
}).catch(() => []),
getIBMPlexMonoMedium(),
getImageResponseCacheControlHeaders(),
]);

View File

@ -14,10 +14,12 @@ import { SHOW_FILM_SIMULATIONS } from '@/site/config';
import { sortTagsObject } from '@/tag';
export const getPhotoSidebarData = () => [
getPhotosCount(),
getUniqueTags().then(sortTagsObject),
getUniqueCameras(),
SHOW_FILM_SIMULATIONS ? getUniqueFilmSimulations() : [],
getPhotosCount().catch(() => 0),
getUniqueTags().then(sortTagsObject).catch(() => []),
getUniqueCameras().catch(() => []),
SHOW_FILM_SIMULATIONS
? getUniqueFilmSimulations().catch(() => [])
: [],
] as const;
export const getPhotoSidebarDataCached = () => [