Refine static optimization environment checks
This commit is contained in:
parent
c5d5500644
commit
0cc1290db5
@ -4,14 +4,14 @@ import PhotoImageResponse from '@/image-response/PhotoImageResponse';
|
||||
import { getIBMPlexMonoMedium } from '@/site/font';
|
||||
import { ImageResponse } from 'next/og';
|
||||
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
||||
import { STATICALLY_OPTIMIZED_OG_IMAGES } from '@/site/config';
|
||||
import { IS_PRODUCTION, STATICALLY_OPTIMIZED_OG_IMAGES } from '@/site/config';
|
||||
import { GENERATE_STATIC_PARAMS_LIMIT, getPhotoIds } from '@/photo/db';
|
||||
import { isNextImageReadyBasedOnPhotos } from '@/photo';
|
||||
|
||||
export let generateStaticParams:
|
||||
(() => Promise<{ photoId: string }[]>) | undefined = undefined;
|
||||
|
||||
if (STATICALLY_OPTIMIZED_OG_IMAGES && process.env.NODE_ENV === 'production') {
|
||||
if (STATICALLY_OPTIMIZED_OG_IMAGES && IS_PRODUCTION) {
|
||||
generateStaticParams = async () => {
|
||||
const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT });
|
||||
return photos.map(photoId => ({ photoId }));
|
||||
|
||||
@ -12,13 +12,13 @@ import {
|
||||
} from '@/site/paths';
|
||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||
import { getPhotosNearIdCachedCached } from '@/photo/cache';
|
||||
import { STATICALLY_OPTIMIZED_PAGES } from '@/site/config';
|
||||
import { IS_PRODUCTION, STATICALLY_OPTIMIZED_PAGES } from '@/site/config';
|
||||
import { GENERATE_STATIC_PARAMS_LIMIT, getPhotoIds } from '@/photo/db';
|
||||
|
||||
export let generateStaticParams:
|
||||
(() => Promise<{ photoId: string }[]>) | undefined = undefined;
|
||||
|
||||
if (STATICALLY_OPTIMIZED_PAGES && process.env.NODE_ENV === 'production') {
|
||||
if (STATICALLY_OPTIMIZED_PAGES && IS_PRODUCTION) {
|
||||
generateStaticParams = async () => {
|
||||
const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT });
|
||||
return photos.map(photoId => ({ photoId }));
|
||||
|
||||
@ -23,6 +23,12 @@ const VERCEL_PROJECT_URL = VERCEL_BRANCH_URL && VERCEL_BRANCH
|
||||
? `${VERCEL_BRANCH_URL.split(`-git-${VERCEL_BRANCH}-`)[0]}.vercel.app`
|
||||
: undefined;
|
||||
|
||||
export const IS_PRODUCTION = process.env.NODE_ENV === 'production' && (
|
||||
// Make environment checks resilient to non-Vercel deployments
|
||||
VERCEL_ENV === 'production' ||
|
||||
!VERCEL_ENV
|
||||
);
|
||||
|
||||
// User-facing domain, potential site title
|
||||
const SITE_DOMAIN =
|
||||
process.env.NEXT_PUBLIC_SITE_DOMAIN ||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user