Don't statically generate hidden photos

This commit is contained in:
Sam Becker 2025-03-20 23:51:59 -05:00
parent 8d31afbed2
commit 32c3fcc656
2 changed files with 8 additions and 6 deletions

View File

@ -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}`);
}

View File

@ -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,