This commit is contained in:
Vula Builder
2026-07-29 18:15:19 +00:00
parent 2a19dcfece
commit b7270774dc
+31
View File
@@ -0,0 +1,31 @@
'use client'
import { useState, useEffect } from 'react'
export interface CmsItem {
id: string
collection: string
title: string | null
data: Record<string, unknown>
status: string
sortOrder: number
scheduledAt: string | null
expiresAt: string | null
publishedAt: string | null
}
export function useVulaContent(collection: string) {
const [items, setItems] = useState<CmsItem[]>([])
const [loading, setLoading] = useState(true)
useEffect(() => {
fetch(`/api/content/${collection}`)
.then(r => r.json())
.then((data: { items?: CmsItem[] }) => {
setItems(data.items ?? [])
setLoading(false)
})
.catch(() => setLoading(false))
}, [collection])
return { items, loading }
}