diff --git a/client/app/routes/comments.ts b/client/app/routes/comments.ts index 28ee3ac..001aa8b 100644 --- a/client/app/routes/comments.ts +++ b/client/app/routes/comments.ts @@ -1,11 +1,12 @@ import { LoaderFunctionArgs, json } from "@remix-run/node"; import { prisma } from "~/lib/prisma.server"; +import { render } from "~/lib/render.server"; export const loader = async ({ request }: LoaderFunctionArgs) => { const postId = new URL(request.url).searchParams.get("postId"); if (!postId) { - return new Response("Missing postId", { status: 400 }); + return new Response("Missing `postId`", { status: 400 }); } const comments = await prisma.post.findMany({ @@ -13,5 +14,9 @@ export const loader = async ({ request }: LoaderFunctionArgs) => { include: { user: true, media: true }, }); + for (const comment of comments) { + comment.content = await render(comment.content); + } + return json({ comments }); }; diff --git a/client/app/routes/discussions_.$id.tsx b/client/app/routes/discussions_.$id.tsx index a00d397..2714c51 100644 --- a/client/app/routes/discussions_.$id.tsx +++ b/client/app/routes/discussions_.$id.tsx @@ -46,7 +46,7 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { }); for (const comment of comments) { - comment.content = await render(comment.content) + comment.content = await render(comment.content); } return json({ @@ -73,7 +73,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => { return redirect("/discussions"); } - return redirect(`/discussions/${post.parentId}`); + return null; } case "POST": {