fix: what happens if we use a dynamic import?

This commit is contained in:
Lucas Smith
2024-03-14 09:20:01 +00:00
parent a9bb559568
commit d6c8a3d32c

View File

@ -1,12 +1,8 @@
import { ImageResponse } from 'next/og';
import { NextResponse } from 'next/server';
import { allBlogPosts } from 'contentlayer/generated';
export const runtime = 'edge';
const contentType = 'image/png';
const IMAGE_SIZE = {
width: 1200,
height: 630,
@ -17,6 +13,8 @@ type BlogPostOpenGraphImageProps = {
};
export async function GET(_request: Request, { params }: BlogPostOpenGraphImageProps) {
const { allBlogPosts } = await import('contentlayer/generated');
const blogPost = allBlogPosts.find((post) => post._raw.flattenedPath === `blog/${params.post}`);
if (!blogPost) {