* Add 'recents' and 'years' categories * Add recents and years visibility config * Add fundamental recent/year queries * Display initial date-based data in sidebar * Adjust recents data type * Remove date rage from sidebar footer * Reformat recents/years in sidebar * Organize years in grid * Rename date -> year * Add year-based views * Split sidebar years into rows * Add years to cmdk menu * Localize 'years' * Create /recents views * Enable recents share modals * Fix recents og image * Statically optimize /recents image * Don't statically optimize /recents page * Update i18n * Add recents to cmdk * Suppress spinner for year badges * Refactor sidebar height calculation * Add recents to sitemap
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { getPhotosCached } from '@/photo/cache';
|
|
import {
|
|
IMAGE_OG_DIMENSION_SMALL,
|
|
MAX_PHOTOS_TO_SHOW_PER_CATEGORY,
|
|
} from '@/image-response';
|
|
import YearImageResponse from
|
|
'@/image-response/YearImageResponse';
|
|
import { getIBMPlexMono } from '@/app/font';
|
|
import { ImageResponse } from 'next/og';
|
|
import { getImageResponseCacheControlHeaders } from '@/image-response/cache';
|
|
import { getUniqueYears } from '@/photo/db/query';
|
|
import { staticallyGenerateCategoryIfConfigured } from '@/app/static';
|
|
|
|
export const generateStaticParams = staticallyGenerateCategoryIfConfigured(
|
|
'years',
|
|
'image',
|
|
getUniqueYears,
|
|
years => years.map(({ year }) => ({ year })),
|
|
);
|
|
|
|
export async function GET(
|
|
_: Request,
|
|
context: { params: Promise<{ year: string }> },
|
|
) {
|
|
const { year } = await context.params;
|
|
|
|
const [
|
|
photos,
|
|
{ fontFamily, fonts },
|
|
headers,
|
|
] = await Promise.all([
|
|
getPhotosCached({
|
|
limit: MAX_PHOTOS_TO_SHOW_PER_CATEGORY,
|
|
year: year,
|
|
}),
|
|
getIBMPlexMono(),
|
|
getImageResponseCacheControlHeaders(),
|
|
]);
|
|
|
|
const { width, height } = IMAGE_OG_DIMENSION_SMALL;
|
|
|
|
return new ImageResponse(
|
|
<YearImageResponse {...{
|
|
year,
|
|
photos,
|
|
width,
|
|
height,
|
|
fontFamily,
|
|
}}/>,
|
|
{ width, height, fonts, headers },
|
|
);
|
|
}
|