diff --git a/src/app/static.ts b/src/app/static.ts index 1495bbdd..3fad0f6d 100644 --- a/src/app/static.ts +++ b/src/app/static.ts @@ -7,7 +7,7 @@ import { STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES, } from '@/app/config'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; -import { getPhotoIds } from '@/photo/db/query'; +import { getPublicPhotoIds } from '@/photo/db/query'; import { depluralize, pluralize } from '@/utility/string'; type StaticOutput = 'page' | 'image'; @@ -23,7 +23,9 @@ export const staticallyGeneratePhotosIfConfigured = (type: StaticOutput) => (type === 'image' && STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES) ) ? async () => { - const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT }); + const photos = await getPublicPhotoIds({ + limit: GENERATE_STATIC_PARAMS_LIMIT, + }); if (IS_BUILDING) { logStaticGenerationDetails(photos.length, `photo ${type}`); } diff --git a/src/photo/db/query.ts b/src/photo/db/query.ts index 96141337..35cffde1 100644 --- a/src/photo/db/query.ts +++ b/src/photo/db/query.ts @@ -527,12 +527,12 @@ export const getPhotosMeta = (options: GetPhotosOptions = {}) => })); }, 'getPhotosMeta'); -export const getPhotoIds = async ({ limit }: { limit?: number }) => +export const getPublicPhotoIds = async ({ limit }: { limit?: number }) => safelyQueryPhotos(() => (limit - ? sql`SELECT id FROM photos LIMIT ${limit}` - : sql`SELECT id FROM photos`) + ? sql`SELECT id FROM photos WHERE hidden IS NOT TRUE LIMIT ${limit}` + : sql`SELECT id FROM photos WHERE hidden IS NOT TRUE`) .then(({ rows }) => rows.map(({ id }) => id as string)) - , 'getPhotoIds'); + , 'getPublicPhotoIds'); export const getPhoto = async ( id: string,