From f0f65246f2100b039e14422a953d9a1e573e6b87 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Wed, 3 Jun 2026 16:38:50 +0000 Subject: [PATCH] Deploy --- src/hooks/useEmDashContent.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/hooks/useEmDashContent.ts diff --git a/src/hooks/useEmDashContent.ts b/src/hooks/useEmDashContent.ts new file mode 100644 index 0000000..e121a6f --- /dev/null +++ b/src/hooks/useEmDashContent.ts @@ -0,0 +1,26 @@ +'use client' +import { useState, useEffect } from 'react' + +export interface CmsItem { + id: string + slug: string + data: Record + publishedAt: string | null +} + +export function useEmDashContent(collection: string) { + const [items, setItems] = useState([]) + 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 } +}