Statically generate tag-based share paths
This commit is contained in:
parent
96f8c18893
commit
c213711e7a
@ -1,8 +1,21 @@
|
||||
import { getPhotoCached } from '@/cache';
|
||||
import PhotoShareModal from '@/photo/PhotoShareModal';
|
||||
import { getPhotos, getUniqueTags } from '@/services/postgres';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export const runtime = 'edge';
|
||||
export async function generateStaticParams() {
|
||||
const params: { params: { photoId: string, tag: string }}[] = [];
|
||||
|
||||
const tags = await getUniqueTags();
|
||||
tags.forEach(async tag => {
|
||||
const photos = await getPhotos({ tag });
|
||||
params.push(...photos.map(photo => ({
|
||||
params: { photoId: photo.id, tag },
|
||||
})));
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
export default async function Share({
|
||||
params: { photoId, tag },
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
import { getPhotosCached } from '@/cache';
|
||||
import SiteGrid from '@/components/SiteGrid';
|
||||
import PhotoGrid from '@/photo/PhotoGrid';
|
||||
import { getUniqueTags } from '@/services/postgres';
|
||||
import TagHeader from '@/tag/TagHeader';
|
||||
import TagShareModal from '@/tag/TagShareModal';
|
||||
|
||||
export const runtime = 'edge';
|
||||
export async function generateStaticParams() {
|
||||
const tags = await getUniqueTags();
|
||||
return tags.map(tag => ({
|
||||
params: { tag },
|
||||
}));
|
||||
}
|
||||
|
||||
export default async function Share({
|
||||
params: { tag },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user