diff --git a/README.md b/README.md index ffb3fa35..c70f6e41 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ Installation ### 6. Optional configuration -- `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage (will result in increased storage usage) +- `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage (results in increased storage usage) +- `NEXT_PUBLIC_STATICALLY_OPTIMIZE = 1` enables PPR and static optimization, i.e., building pages ahead of time (results in increased storage usage)—⚠️ _Experimental_ - `NEXT_PUBLIC_BLUR_DISABLED = 1` prevents image blur data being stored and displayed (potentially useful for limiting Postgres usage) - `NEXT_PUBLIC_GEO_PRIVACY = 1` disables collection/display of location-based data - `NEXT_PUBLIC_IGNORE_PRIORITY_ORDER = 1` prevents `priority_order` field affecting photo order diff --git a/next.config.js b/next.config.js index c6ea678c..a18d28c6 100644 --- a/next.config.js +++ b/next.config.js @@ -35,8 +35,8 @@ const nextConfig = { .concat(createRemotePattern(AWS_S3_HOSTNAME)), minimumCacheTTL: 31536000, }, - experimental: { - ppr: true, + ...process.env.NEXT_PUBLIC_STATICALLY_OPTIMIZE === '1' && { + experimental: { ppr: true }, }, }; diff --git a/src/app/p/[photoId]/layout.tsx b/src/app/p/[photoId]/layout.tsx index 41ef856d..81004543 100644 --- a/src/app/p/[photoId]/layout.tsx +++ b/src/app/p/[photoId]/layout.tsx @@ -14,12 +14,17 @@ import { import PhotoDetailPage from '@/photo/PhotoDetailPage'; import { getPhotosNearIdCached } from '@/photo/cache'; import { getPhotoIds } from '@/services/vercel-postgres'; +import { STATICALLY_OPTIMIZED } from '@/site/config'; export async function generateStaticParams() { - const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT }); - return photos.map(photoId => ({ - params: { photoId }, - })); + if (STATICALLY_OPTIMIZED) { + const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT }); + return photos.map(photoId => ({ + params: { photoId }, + })); + } else { + return []; + } } interface PhotoProps { diff --git a/src/components/Badge.tsx b/src/components/Badge.tsx index 67461974..34102ab3 100644 --- a/src/components/Badge.tsx +++ b/src/components/Badge.tsx @@ -2,12 +2,14 @@ import { clsx } from 'clsx/lite'; export default function Badge({ children, + className, type = 'large', highContrast, uppercase, interactive, }: { children: React.ReactNode + className?: string type?: 'large' | 'small' | 'text-only' highContrast?: boolean uppercase?: boolean @@ -39,6 +41,7 @@ export default function Badge({ }; return (