Statically optimize photo categories when configured
This commit is contained in:
parent
862b94c96c
commit
27552590af
@ -1,13 +1,26 @@
|
|||||||
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
||||||
|
import { getUniqueFilmSimulations } from '@/photo/db/query';
|
||||||
import { FilmSimulation, generateMetaForFilmSimulation } from '@/simulation';
|
import { FilmSimulation, generateMetaForFilmSimulation } from '@/simulation';
|
||||||
import FilmSimulationOverview from '@/simulation/FilmSimulationOverview';
|
import FilmSimulationOverview from '@/simulation/FilmSimulationOverview';
|
||||||
|
import { IS_PRODUCTION } from '@/site/config';
|
||||||
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
import { getPhotosFilmSimulationDataCached } from '@/simulation/data';
|
||||||
|
import { STATICALLY_OPTIMIZED_PHOTO_CATEGORIES } from '@/site/config';
|
||||||
import { Metadata } from 'next/types';
|
import { Metadata } from 'next/types';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
|
|
||||||
const getPhotosFilmSimulationDataCachedCached =
|
const getPhotosFilmSimulationDataCachedCached =
|
||||||
cache(getPhotosFilmSimulationDataCached);
|
cache(getPhotosFilmSimulationDataCached);
|
||||||
|
|
||||||
|
export let generateStaticParams:
|
||||||
|
(() => Promise<{ simulation: FilmSimulation }[]>) | undefined = undefined;
|
||||||
|
|
||||||
|
if (STATICALLY_OPTIMIZED_PHOTO_CATEGORIES && IS_PRODUCTION) {
|
||||||
|
generateStaticParams = async () => {
|
||||||
|
const simulations = await getUniqueFilmSimulations();
|
||||||
|
return simulations.map(({ simulation }) => ({ simulation }));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface FilmSimulationProps {
|
interface FilmSimulationProps {
|
||||||
params: Promise<{ simulation: FilmSimulation }>
|
params: Promise<{ simulation: FilmSimulation }>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,9 @@ import { generateMetaForFocalLength, getFocalLengthFromString } from '@/focal';
|
|||||||
import FocalLengthOverview from '@/focal/FocalLengthOverview';
|
import FocalLengthOverview from '@/focal/FocalLengthOverview';
|
||||||
import { getPhotosFocalLengthDataCached } from '@/focal/data';
|
import { getPhotosFocalLengthDataCached } from '@/focal/data';
|
||||||
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
||||||
|
import { IS_PRODUCTION } from '@/site/config';
|
||||||
|
import { getUniqueFocalLengths } from '@/photo/db/query';
|
||||||
|
import { STATICALLY_OPTIMIZED_PHOTO_CATEGORIES } from '@/site/config';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
import type { Metadata } from 'next';
|
import type { Metadata } from 'next';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
@ -13,6 +16,16 @@ const getPhotosFocalDataCachedCached = cache((focal: number) =>
|
|||||||
limit: INFINITE_SCROLL_GRID_INITIAL,
|
limit: INFINITE_SCROLL_GRID_INITIAL,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export let generateStaticParams:
|
||||||
|
(() => Promise<{ focal: string }[]>) | undefined = undefined;
|
||||||
|
|
||||||
|
if (STATICALLY_OPTIMIZED_PHOTO_CATEGORIES && IS_PRODUCTION) {
|
||||||
|
generateStaticParams = async () => {
|
||||||
|
const focalLengths = await getUniqueFocalLengths();
|
||||||
|
return focalLengths.map(({ focal }) => ({ focal: focal.toString() }));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface FocalLengthProps {
|
interface FocalLengthProps {
|
||||||
params: Promise<{ focal: string }>
|
params: Promise<{ focal: string }>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,9 @@ import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
|||||||
import { getPhotosCameraDataCached } from '@/camera/data';
|
import { getPhotosCameraDataCached } from '@/camera/data';
|
||||||
import CameraOverview from '@/camera/CameraOverview';
|
import CameraOverview from '@/camera/CameraOverview';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
|
import { STATICALLY_OPTIMIZED_PHOTO_CATEGORIES } from '@/site/config';
|
||||||
|
import { IS_PRODUCTION } from '@/site/config';
|
||||||
|
import { getUniqueCameras } from '@/photo/db/query';
|
||||||
|
|
||||||
const getPhotosCameraDataCachedCached = cache((
|
const getPhotosCameraDataCachedCached = cache((
|
||||||
make: string,
|
make: string,
|
||||||
@ -15,6 +18,16 @@ const getPhotosCameraDataCachedCached = cache((
|
|||||||
INFINITE_SCROLL_GRID_INITIAL,
|
INFINITE_SCROLL_GRID_INITIAL,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
export let generateStaticParams:
|
||||||
|
(() => Promise<{ make: string, model: string }[]>) | undefined = undefined;
|
||||||
|
|
||||||
|
if (STATICALLY_OPTIMIZED_PHOTO_CATEGORIES && IS_PRODUCTION) {
|
||||||
|
generateStaticParams = async () => {
|
||||||
|
const cameras = await getUniqueCameras();
|
||||||
|
return cameras.map(({ camera: { make, model } }) => ({ make, model }));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params,
|
params,
|
||||||
}: CameraProps): Promise<Metadata> {
|
}: CameraProps): Promise<Metadata> {
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
||||||
|
import { getUniqueTags } from '@/photo/db/query';
|
||||||
|
import { IS_PRODUCTION } from '@/site/config';
|
||||||
|
import { STATICALLY_OPTIMIZED_PHOTO_CATEGORIES } from '@/site/config';
|
||||||
import { PATH_ROOT } from '@/site/paths';
|
import { PATH_ROOT } from '@/site/paths';
|
||||||
import { generateMetaForTag } from '@/tag';
|
import { generateMetaForTag } from '@/tag';
|
||||||
import TagOverview from '@/tag/TagOverview';
|
import TagOverview from '@/tag/TagOverview';
|
||||||
@ -10,6 +13,16 @@ import { cache } from 'react';
|
|||||||
const getPhotosTagDataCachedCached = cache((tag: string) =>
|
const getPhotosTagDataCachedCached = cache((tag: string) =>
|
||||||
getPhotosTagDataCached({ tag, limit: INFINITE_SCROLL_GRID_INITIAL}));
|
getPhotosTagDataCached({ tag, limit: INFINITE_SCROLL_GRID_INITIAL}));
|
||||||
|
|
||||||
|
export let generateStaticParams:
|
||||||
|
(() => Promise<{ tag: string }[]>) | undefined = undefined;
|
||||||
|
|
||||||
|
if (STATICALLY_OPTIMIZED_PHOTO_CATEGORIES && IS_PRODUCTION) {
|
||||||
|
generateStaticParams = async () => {
|
||||||
|
const tags = await getUniqueTags();
|
||||||
|
return tags.map(({ tag }) => ({ tag }));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface TagProps {
|
interface TagProps {
|
||||||
params: Promise<{ tag: string }>
|
params: Promise<{ tag: string }>
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user