Fix tag text image generation

This commit is contained in:
Sam Becker 2023-09-22 11:02:30 -05:00
parent 1edb480321
commit 68dab11e6b
2 changed files with 14 additions and 6 deletions

View File

@ -11,15 +11,14 @@ import { ImageResponse } from 'next/server';
export const runtime = 'edge';
export async function GET(request: Request, context: any) {
const tag = context.params.tag as string;
const [
photos,
{ fontFamily, fonts },
headers,
] = await Promise.all([
getPhotosCached({
limit: MAX_PHOTOS_TO_SHOW_PER_TAG,
tag: context.params.tag,
}),
getPhotosCached({ limit: MAX_PHOTOS_TO_SHOW_PER_TAG, tag }),
getIBMPlexMonoMedium(),
getImageCacheHeadersForAuth(await auth()),
]);
@ -27,7 +26,14 @@ export async function GET(request: Request, context: any) {
const { width, height } = IMAGE_OG_SMALL_SIZE;
return new ImageResponse(
<TagImageResponse {...{ photos, request, width, height, fontFamily }}/>,
<TagImageResponse {...{
tag,
photos,
request,
width,
height,
fontFamily,
}}/>,
{ width, height, fonts, headers },
);
}

View File

@ -5,12 +5,14 @@ import ImagePhotoGrid from './components/ImagePhotoGrid';
import ImageContainer from './components/ImageContainer';
export default function TagImageResponse({
tag,
photos,
request,
width,
height,
fontFamily,
}: {
tag: string,
photos: Photo[]
request: Request
width: number
@ -36,7 +38,7 @@ export default function TagImageResponse({
size={height * .067}
style={{ transform: `translateY(${height * .02}px)` }}
/>
<span>{'Door County'.toUpperCase()}</span>
<span>{tag.toUpperCase()}</span>
</ImageCaption>
</ImageContainer>
);