import LayoutWrapper from '@/app/components/layouts/LayoutWrapper' import React from 'react' import Link from 'next/link'; import { SignedOut } from '@clerk/nextjs'; import { Info } from 'lucide-react'; import Form from '../../../../components/comments/Form'; import { prisma } from "../../../../../db"; import Comment from '../../../../components/comments/Comment'; import { Post } from '@/lib/interface'; import { notFound } from 'next/navigation'; import { client } from '@/lib/sanity'; import NavButton from '@/app/components/misc/NavButton'; async function getEntries() { const data = await prisma.comments.findMany({ take: 50, orderBy: { created_at: "desc", }, }); return data; } async function getData(slug: string) { const query = `*[_type == "post" && slug.current == "${slug}"][0]`; const data = await client.fetch(query); return data; } const CommentPage = async ({ params, }: { params: { blogId: string }; }) => { const data = (await getData(params.blogId)) as Post; if (!data) return notFound() async function getFilteredComments() { const entries = await getEntries(); const filteredComments = entries.filter(res => res.blogName === params.blogId); return filteredComments; } const comments = await getFilteredComments() return (

Comments

Sign in to comment

{data.title}

{ comments.length > 0 && comments.map((entry) => (
))} {comments.length === 0 && (

Be the first to comment!

)}
) } export default CommentPage