feat: replace textarea with rich text editor for form descriptions and add metadata support with HTML rendering
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user