(data: any)
| 17 | import { BLOGS, COMMENTS } from "@/constant/article"; |
| 18 | |
| 19 | export async function addBlog(data: any) { |
| 20 | try { |
| 21 | const docRef = await addDoc(collection(db, BLOGS), { |
| 22 | ...data, |
| 23 | createdAt: new Date(), |
| 24 | }); |
| 25 | return docRef.id; |
| 26 | } catch (error) { |
| 27 | console.error("Error adding blog:", error); |
| 28 | throw error; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | export async function getBlogs(max?: number, lastDoc?: any): Promise<any> { |
| 33 | try { |