diff --git a/app/admin/form/[id]/client.tsx b/app/admin/form/[id]/client.tsx
index 0d14c72..725aab3 100644
--- a/app/admin/form/[id]/client.tsx
+++ b/app/admin/form/[id]/client.tsx
@@ -309,12 +309,11 @@ export default function FormEditorClient({ form, initialQuestions }: FormEditorC
-
diff --git a/app/form/[id]/layout.tsx b/app/form/[id]/layout.tsx
new file mode 100644
index 0000000..f7eda69
--- /dev/null
+++ b/app/form/[id]/layout.tsx
@@ -0,0 +1,42 @@
+import { db } from "@/db";
+import { Metadata } from "next";
+
+export async function generateMetadata(
+ props: { params: Promise<{ id: string }> }
+): Promise
{
+ 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;
+}
diff --git a/app/form/client.tsx b/app/form/client.tsx
index f133e39..2d79dbe 100644
--- a/app/form/client.tsx
+++ b/app/form/client.tsx
@@ -20,7 +20,7 @@ import { Loader2, LogOut } from "lucide-react";
import { signOut } from "next-auth/react";
import Image from "next/image";
import { z } from "zod";
-import { useForm } from "react-hook-form";
+import { useForm, Controller } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import {
Form,
@@ -249,9 +249,9 @@ export function FormFillerClient({ form, questions, initialAnswers = {} }: FormF
{form.title}
{form.description && (
-
- {form.description}
-
+
+
+
)}
diff --git a/app/form/layout.tsx b/app/form/layout.tsx
index 78f73c0..f5c5f0a 100644
--- a/app/form/layout.tsx
+++ b/app/form/layout.tsx
@@ -9,10 +9,7 @@ import Link from 'next/link';
const siteUrl = process.env.BASE_URL;
export const metadata: Metadata = {
- title: {
- default: "กรอกแบบฟอร์ม",
- template: "%s | Erika!",
- },
+ title: "กรอกแบบฟอร์ม",
openGraph: {
type: "website",
locale: "th_TH",
diff --git a/app/form/page.tsx b/app/form/page.tsx
index d7d8c4a..823e068 100644
--- a/app/form/page.tsx
+++ b/app/form/page.tsx
@@ -6,6 +6,7 @@ import {
CardTitle,
CardDescription,
} from "@/components/ui/card";
+import { HtmlDisplay } from "@/components/html-display";
export const dynamic = "force-dynamic";
@@ -28,9 +29,9 @@ export default async function FormsListingPage() {
{form.title}
{form.description && (
-
- {form.description}
-
+
+
+
)}