Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 21s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m36s
Build & Deploy KLZ Cables / 🏗️ Build & Push (push) Failing after 1m31s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Has been skipped
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 3s
32 lines
788 B
TypeScript
32 lines
788 B
TypeScript
import { ImageResponse } from 'next/og';
|
|
import { getPageBySlug } from '@/lib/pages';
|
|
import { OGImageTemplate } from '@/components/OGImageTemplate';
|
|
import { getOgFonts, OG_IMAGE_SIZE } from '@/lib/og-helper';
|
|
|
|
export const runtime = 'nodejs';
|
|
|
|
export default async function Image({ params: { locale, slug } }: { params: { locale: string, slug: string } }) {
|
|
const pageData = await getPageBySlug(slug, locale);
|
|
|
|
if (!pageData) {
|
|
return new Response('Page not found', { status: 404 });
|
|
}
|
|
|
|
const fonts = await getOgFonts();
|
|
|
|
return new ImageResponse(
|
|
(
|
|
<OGImageTemplate
|
|
title={pageData.frontmatter.title}
|
|
description={pageData.frontmatter.excerpt}
|
|
label="Information"
|
|
/>
|
|
),
|
|
{
|
|
...OG_IMAGE_SIZE,
|
|
fonts,
|
|
}
|
|
);
|
|
}
|
|
|