From 3ce519f0e1e9989122d0e1d65314fa45ec76f737 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Wed, 29 Jul 2026 19:04:15 +0000 Subject: [PATCH] Deploy --- src/hooks/useVulaContent.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/hooks/useVulaContent.ts diff --git a/src/hooks/useVulaContent.ts b/src/hooks/useVulaContent.ts new file mode 100644 index 0000000..9543911 --- /dev/null +++ b/src/hooks/useVulaContent.ts @@ -0,0 +1,31 @@ +'use client' +import { useState, useEffect } from 'react' + +export interface CmsItem { + id: string + collection: string + title: string | null + data: Record + status: string + sortOrder: number + scheduledAt: string | null + expiresAt: string | null + publishedAt: string | null +} + +export function useVulaContent(collection: string) { + const [items, setItems] = useState([]) + 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 } +}