This commit is contained in:
Vula Builder
2026-06-04 09:16:59 +00:00
parent 0dd831cefc
commit 9e94af1ba4
+26
View File
@@ -0,0 +1,26 @@
'use client'
import { useState, useEffect } from 'react'
export interface CmsItem {
id: string
slug: string
data: Record<string, unknown>
publishedAt: string | null
}
export function useEmDashContent(collection: string) {
const [items, setItems] = useState<CmsItem[]>([])
const [loading, setLoading] = useState(true)
useEffect(() => {
fetch(`/api/emdash/${collection}`)
.then(r => r.json())
.then((data: { items?: CmsItem[] }) => {
setItems(data.items ?? [])
setLoading(false)
})
.catch(() => setLoading(false))
}, [collection])
return { items, loading }
}