diff --git a/src/app/static.ts b/src/app/static.ts index be50d1a1..8dbd4d1a 100644 --- a/src/app/static.ts +++ b/src/app/static.ts @@ -12,6 +12,8 @@ import { getAllPublicPhotoIds } from '@/photo/query'; import { depluralize, pluralize } from '@/utility/string'; type StaticOutput = 'page' | 'image'; +const STATIC_GENERATION_DISABLED = + process.env.DISABLE_STATIC_GENERATION === '1'; const logStaticGenerationDetails = (count: number, content: string) => { if (count > 0) { @@ -21,9 +23,10 @@ const logStaticGenerationDetails = (count: number, content: string) => { }; export const staticallyGeneratePhotosIfConfigured = (type: StaticOutput) => ( + !STATIC_GENERATION_DISABLED && ( (type === 'page' && STATICALLY_OPTIMIZED_PHOTOS) || (type === 'image' && STATICALLY_OPTIMIZED_PHOTO_OG_IMAGES) -) +)) ? async () => { const photoIds = await getAllPublicPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT, @@ -45,6 +48,7 @@ export const staticallyGenerateCategoryIfConfigured = ( getData: () => Promise, formatData: (data: T[]) => K[], ): (() => Promise) | undefined => + !STATIC_GENERATION_DISABLED && CATEGORY_VISIBILITY.includes(key) && ( (type === 'page' && STATICALLY_OPTIMIZED_PHOTO_CATEGORIES) || (type === 'image' && STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES) diff --git a/src/db/index.ts b/src/db/index.ts index c13c8d6a..9ab273aa 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -9,7 +9,14 @@ import { getAlbumFromSlug } from '@/album/query'; import { isTagPrivate } from '@/tag'; import { getPhotoCount } from '@/photo/query'; -export const GENERATE_STATIC_PARAMS_LIMIT = 1000; +const staticParamsLimitRaw = parseInt( + process.env.GENERATE_STATIC_PARAMS_LIMIT || '1000', + 10, +); +export const GENERATE_STATIC_PARAMS_LIMIT = + Number.isFinite(staticParamsLimitRaw) && staticParamsLimitRaw > 0 + ? staticParamsLimitRaw + : 1000; export const PHOTO_DEFAULT_LIMIT = 100; // These must mirror utility/string.ts parameterization