* 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
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import { INFINITE_SCROLL_GRID_INITIAL } from '@/photo';
|
|
import { generateMetaForRecents } from '@/recents/meta';
|
|
import RecentsOverview from '@/recents/RecentsOverview';
|
|
import { getPhotosRecentsDataCached } from '@/recents/data';
|
|
import { Metadata } from 'next/types';
|
|
import { cache } from 'react';
|
|
import { PATH_ROOT } from '@/app/paths';
|
|
import { redirect } from 'next/navigation';
|
|
import { getAppText } from '@/i18n/state/server';
|
|
|
|
const getPhotosRecentsDataCachedCached = cache(() =>
|
|
getPhotosRecentsDataCached({ limit: INFINITE_SCROLL_GRID_INITIAL }));
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
const [
|
|
photos,
|
|
{ count, dateRange },
|
|
] = await getPhotosRecentsDataCachedCached();
|
|
|
|
if (photos.length === 0) { return {}; }
|
|
|
|
const appText = await getAppText();
|
|
|
|
const {
|
|
url,
|
|
title,
|
|
description,
|
|
images,
|
|
} = generateMetaForRecents(photos, appText, count, dateRange);
|
|
|
|
return {
|
|
title,
|
|
openGraph: {
|
|
title,
|
|
description,
|
|
images,
|
|
url,
|
|
},
|
|
twitter: {
|
|
images,
|
|
description,
|
|
card: 'summary_large_image',
|
|
},
|
|
description,
|
|
};
|
|
}
|
|
|
|
export default async function RecentsPage() {
|
|
const [
|
|
photos,
|
|
{ count, dateRange },
|
|
] = await getPhotosRecentsDataCachedCached();
|
|
|
|
if (photos.length === 0) { redirect(PATH_ROOT); }
|
|
|
|
return (
|
|
<RecentsOverview {...{
|
|
photos,
|
|
count,
|
|
dateRange,
|
|
}} />
|
|
);
|
|
}
|