mirror of
https://github.com/dathere/ckanaction.git
synced 2025-12-19 08:49:26 +00:00
36 lines
826 B
TypeScript
36 lines
826 B
TypeScript
import { getPageImage, source } from '@/lib/source';
|
|
import { notFound } from 'next/navigation';
|
|
import { ImageResponse } from 'next/og';
|
|
import { generate as DefaultImage } from 'fumadocs-ui/og';
|
|
|
|
export const revalidate = false;
|
|
|
|
export async function GET(
|
|
_req: Request,
|
|
{ params }: RouteContext<'/og/docs/[...slug]'>,
|
|
) {
|
|
const { slug } = await params;
|
|
const page = source.getPage(slug.slice(0, -1));
|
|
if (!page) notFound();
|
|
|
|
return new ImageResponse(
|
|
(
|
|
<DefaultImage
|
|
title={page.data.title}
|
|
description={page.data.description}
|
|
site="ckanaction"
|
|
/>
|
|
),
|
|
{
|
|
width: 1200,
|
|
height: 630,
|
|
},
|
|
);
|
|
}
|
|
|
|
export function generateStaticParams() {
|
|
return source.getPages().map((page) => ({
|
|
lang: page.locale,
|
|
slug: getPageImage(page).segments,
|
|
}));
|
|
}
|