diff --git a/__tests__/set.test.ts b/__tests__/category.test.ts similarity index 100% rename from __tests__/set.test.ts rename to __tests__/category.test.ts diff --git a/app/film/[simulation]/image/route.tsx b/app/film/[simulation]/image/route.tsx index 6b522eb5..243b6043 100644 --- a/app/film/[simulation]/image/route.tsx +++ b/app/film/[simulation]/image/route.tsx @@ -11,7 +11,7 @@ import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { getUniqueFilmSimulations } from '@/photo/db/query'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; export let generateStaticParams: (() => Promise<{ simulation: FilmSimulation }[]>) | undefined = undefined; diff --git a/app/film/[simulation]/page.tsx b/app/film/[simulation]/page.tsx index f66c28f6..b2d4962b 100644 --- a/app/film/[simulation]/page.tsx +++ b/app/film/[simulation]/page.tsx @@ -7,8 +7,9 @@ import { Metadata } from 'next/types'; import { cache } from 'react'; import { PATH_ROOT } from '@/app/paths'; import { redirect } from 'next/navigation'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; + const getPhotosFilmSimulationDataCachedCached = cache(getPhotosFilmSimulationDataCached); diff --git a/app/focal/[focal]/image/route.tsx b/app/focal/[focal]/image/route.tsx index e5904c4a..5cfcbe70 100644 --- a/app/focal/[focal]/image/route.tsx +++ b/app/focal/[focal]/image/route.tsx @@ -11,7 +11,7 @@ import FocalLengthImageResponse from import { formatFocalLength, getFocalLengthFromString } from '@/focal'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { getUniqueFocalLengths } from '@/photo/db/query'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; export let generateStaticParams: (() => Promise<{ focal: string }[]>) | undefined = undefined; diff --git a/app/focal/[focal]/page.tsx b/app/focal/[focal]/page.tsx index b08b496c..1ed3942c 100644 --- a/app/focal/[focal]/page.tsx +++ b/app/focal/[focal]/page.tsx @@ -7,7 +7,7 @@ import { PATH_ROOT } from '@/app/paths'; import type { Metadata } from 'next'; import { redirect } from 'next/navigation'; import { cache } from 'react'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; const getPhotosFocalDataCachedCached = cache((focal: number) => diff --git a/app/lens/[make]/[model]/image/route.tsx b/app/lens/[make]/[model]/image/route.tsx index bc2621f8..99e0fd28 100644 --- a/app/lens/[make]/[model]/image/route.tsx +++ b/app/lens/[make]/[model]/image/route.tsx @@ -15,7 +15,7 @@ import { safelyGenerateLensStaticParams, } from '@/lens'; import LensImageResponse from '@/image-response/LensImageResponse'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; export let generateStaticParams: (() => Promise) | undefined = undefined; diff --git a/app/lens/[make]/[model]/page.tsx b/app/lens/[make]/[model]/page.tsx index 2eca315b..b80d1d0d 100644 --- a/app/lens/[make]/[model]/page.tsx +++ b/app/lens/[make]/[model]/page.tsx @@ -12,7 +12,7 @@ import { safelyGenerateLensStaticParams, } from '@/lens'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; const getPhotosLensDataCachedCached = cache(( make: string | undefined, diff --git a/app/recipe/[recipe]/image/route.tsx b/app/recipe/[recipe]/image/route.tsx index c95767e4..7777a247 100644 --- a/app/recipe/[recipe]/image/route.tsx +++ b/app/recipe/[recipe]/image/route.tsx @@ -9,7 +9,7 @@ import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { getUniqueRecipes } from '@/photo/db/query'; import RecipeImageResponse from '@/image-response/RecipeImageResponse'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; export let generateStaticParams: (() => Promise<{ recipe: string }[]>) | undefined = undefined; diff --git a/app/recipe/[recipe]/page.tsx b/app/recipe/[recipe]/page.tsx index c9bfa2db..783fb1c2 100644 --- a/app/recipe/[recipe]/page.tsx +++ b/app/recipe/[recipe]/page.tsx @@ -7,7 +7,7 @@ import { cache } from 'react'; import { generateMetaForRecipe } from '@/recipe'; import RecipeOverview from '@/recipe/RecipeOverview'; import { getPhotosRecipeDataCached } from '@/recipe/data'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; const getPhotosRecipeDataCachedCached = cache(getPhotosRecipeDataCached); diff --git a/app/shot-on/[make]/[model]/image/route.tsx b/app/shot-on/[make]/[model]/image/route.tsx index 946c0f38..cf178f8b 100644 --- a/app/shot-on/[make]/[model]/image/route.tsx +++ b/app/shot-on/[make]/[model]/image/route.tsx @@ -10,7 +10,7 @@ import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { getUniqueCameras } from '@/photo/db/query'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; export let generateStaticParams: (() => Promise<{ camera: Camera }[]>) | undefined = undefined; diff --git a/app/shot-on/[make]/[model]/page.tsx b/app/shot-on/[make]/[model]/page.tsx index e4680731..79b3e971 100644 --- a/app/shot-on/[make]/[model]/page.tsx +++ b/app/shot-on/[make]/[model]/page.tsx @@ -6,7 +6,7 @@ import { getPhotosCameraDataCached } from '@/camera/data'; import CameraOverview from '@/camera/CameraOverview'; import { cache } from 'react'; import { getUniqueCameras } from '@/photo/db/query'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; const getPhotosCameraDataCachedCached = cache(( diff --git a/app/tag/[tag]/image/route.tsx b/app/tag/[tag]/image/route.tsx index 1016c71b..43c9dd74 100644 --- a/app/tag/[tag]/image/route.tsx +++ b/app/tag/[tag]/image/route.tsx @@ -9,7 +9,7 @@ import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { getUniqueTags } from '@/photo/db/query'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; export let generateStaticParams: (() => Promise<{ tag: string }[]>) | undefined = undefined; diff --git a/app/tag/[tag]/page.tsx b/app/tag/[tag]/page.tsx index b1d003ba..e06b2b8e 100644 --- a/app/tag/[tag]/page.tsx +++ b/app/tag/[tag]/page.tsx @@ -7,7 +7,7 @@ import { getPhotosTagDataCached } from '@/tag/data'; import type { Metadata } from 'next'; import { redirect } from 'next/navigation'; import { cache } from 'react'; -import { shouldGenerateStaticParamsForCategory } from '@/category'; +import { shouldGenerateStaticParamsForCategory } from '@/app/config'; import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; const getPhotosTagDataCachedCached = cache((tag: string) => diff --git a/src/app/config.ts b/src/app/config.ts index 3b27af06..eca9b5ef 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -2,7 +2,7 @@ import { AI_AUTO_GENERATED_FIELDS_DEFAULT, parseAiAutoGeneratedFieldsString, } from '@/photo/ai'; -import { getOrderedCategoriesFromString } from '@/category'; +import { CategoryKey, getOrderedCategoriesFromString } from '@/category'; import type { StorageType } from '@/platforms/storage'; import { makeUrlAbsolute, shortenUrl } from '@/utility/url'; @@ -184,6 +184,17 @@ export const HAS_STATIC_OPTIMIZATION = STATICALLY_OPTIMIZED_PHOTO_OG_IMAGES || STATICALLY_OPTIMIZED_PHOTO_CATEGORIES || STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES; + +export const shouldGenerateStaticParamsForCategory = ( + key: CategoryKey, + type: 'page' | 'image', +): boolean => + CATEGORY_VISIBILITY.includes(key) && + IS_PRODUCTION && ( + (type === 'page' && STATICALLY_OPTIMIZED_PHOTO_CATEGORIES) || + (type === 'image' && STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES) + ); + export const PRESERVE_ORIGINAL_UPLOADS = process.env.NEXT_PUBLIC_PRESERVE_ORIGINAL_UPLOADS === '1' || // Legacy environment variable name @@ -195,6 +206,7 @@ export const IMAGE_QUALITY = export const BLUR_ENABLED = process.env.NEXT_PUBLIC_BLUR_DISABLED !== '1'; + // VISUAL export const DEFAULT_THEME = diff --git a/src/category/index.ts b/src/category/index.ts index b8a004dd..970c97f9 100644 --- a/src/category/index.ts +++ b/src/category/index.ts @@ -6,12 +6,6 @@ import { Lens, Lenses } from '@/lens'; import { Tags } from '@/tag'; import { FocalLengths } from '@/focal'; import { Recipes } from '@/recipe'; -import { - CATEGORY_VISIBILITY, - IS_PRODUCTION, - STATICALLY_OPTIMIZED_PHOTO_CATEGORIES, - STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES, -} from '@/app/config'; const CATEGORY_KEYS = [ 'cameras', @@ -22,9 +16,9 @@ const CATEGORY_KEYS = [ 'focal-lengths', ] as const; -type CategoryKey = (typeof CATEGORY_KEYS)[number]; +export type CategoryKey = (typeof CATEGORY_KEYS)[number]; -type CategoryKeys = CategoryKey[]; +export type CategoryKeys = CategoryKey[]; export const DEFAULT_CATEGORY_KEYS: CategoryKeys = [ 'tags', @@ -33,16 +27,6 @@ export const DEFAULT_CATEGORY_KEYS: CategoryKeys = [ 'films', ]; -export const shouldGenerateStaticParamsForCategory = ( - key: CategoryKey, - type: 'page' | 'image', -): boolean => - CATEGORY_VISIBILITY.includes(key) && - IS_PRODUCTION && ( - (type === 'page' && STATICALLY_OPTIMIZED_PHOTO_CATEGORIES) || - (type === 'image' && STATICALLY_OPTIMIZED_PHOTO_CATEGORY_OG_IMAGES) - ); - export const getHiddenCategories = (keys: CategoryKeys): CategoryKeys => CATEGORY_KEYS.filter(key => !keys.includes(key));