43 lines
892 B
TypeScript
43 lines
892 B
TypeScript
import { db } from "@/db";
|
|
import { Metadata } from "next";
|
|
|
|
export async function generateMetadata(
|
|
props: { params: Promise<{ id: string }> }
|
|
): Promise<Metadata> {
|
|
const params = await props.params;
|
|
|
|
const form = await db.query.forms.findFirst({
|
|
where: (f, { eq }) => eq(f.id, params.id),
|
|
});
|
|
|
|
if (!form) {
|
|
return {
|
|
title: "Not Found",
|
|
description: "Form not found",
|
|
};
|
|
}
|
|
|
|
const cleanDescription = form.description ? form.description.replace(/<[^>]*>?/gm, '') : "แบบฟอร์ม";
|
|
|
|
return {
|
|
title: form.title,
|
|
description: cleanDescription,
|
|
openGraph: {
|
|
title: form.title,
|
|
description: cleanDescription,
|
|
},
|
|
twitter: {
|
|
title: form.title,
|
|
description: cleanDescription,
|
|
},
|
|
};
|
|
}
|
|
|
|
export default function FormIdLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
return children;
|
|
}
|