feat: replace textarea with rich text editor for form descriptions and add metadata support with HTML rendering

This commit is contained in:
2026-06-29 19:13:37 +07:00 Unverified
parent 45ceae5c6e
commit 3b004e393c
5 changed files with 54 additions and 15 deletions
+42
View File
@@ -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;
}