Make static pages resilient to db-less installation

This commit is contained in:
Sam Becker 2024-04-29 23:08:58 -05:00
parent 5635ac500a
commit cd731ab56b
9 changed files with 24 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

@ -17,7 +17,7 @@ export async function GET() {
headers,
{ fontFamily, fonts },
] = await Promise.all([
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }),
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_OG }).catch(() => []),
getImageResponseCacheControlHeaders(),
getIBMPlexMonoMedium(),
]);

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 = () => [