portfolio/lib/getComments.ts
Ryan Freeman f8d668e4f3
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m18s
Render comments on server
2025-03-27 20:53:49 +00:00

24 lines
724 B
TypeScript

import {createClient} from '@/lib/supabase/client'
export async function getComments(slug: string) {
try {
const supabase = await createClient()
const {data: comments, error} = await supabase
.from('comments')
.select(`
id,
content,
published,
created_at,
user:users!inner(id, name, image),
article:articles!inner(id, title, slug)
`)
.eq('article.slug', slug)
.eq('published', true)
.order('created_at', {ascending: false})
return comments
} catch (error) {
console.error(error)
}
}