diff --git a/src/components/sections/WokStoriesBlogSection.tsx b/src/components/sections/WokStoriesBlogSection.tsx new file mode 100644 index 0000000..792b503 --- /dev/null +++ b/src/components/sections/WokStoriesBlogSection.tsx @@ -0,0 +1,164 @@ +'use client' + +import Image from 'next/image' +import Link from 'next/link' +import { ArrowRight, UtensilsCrossed } from 'lucide-react' +import Badge from '@/components/ui/Badge' +import { useVulaContent } from '@/hooks/useVulaContent' + +type PostFields = { + title?: string + excerpt?: string + body?: string + author?: string + category?: string + image?: string + url?: string +} + +const trim = (text: string, max: number) => { + if (text.length <= max) return text + return `${text.slice(0, max).trimEnd()}…` +} + +export default function WokStoriesBlogSection() { + const { items, loading } = useVulaContent('posts') + + if (loading) { + return ( +
+
+
+ ) + } + + if (items.length === 0) return null + + const posts = items.map((item) => { + const d = item.data as PostFields + return { + id: item.id, + title: d.title ?? '', + excerpt: d.excerpt ?? '', + body: d.body ?? '', + author: d.author ?? '', + category: d.category ?? '', + image: d.image ?? '', + href: d.url ?? '', + } + }) + + const lead = posts[0] + const rest = posts.slice(1) + + return ( +
+
+
+
+
+
+

+ What happens between order and box. +

+
+

+ Notes from the corner — new things going into the wok, what the street asked us to try next, and the people who keep coming back. +

+
+ +
+
+
+ {lead.image ? ( + {lead.title + ) : ( +
+
+ )} +
+
+ {lead.category ? {lead.category} : null} +

{lead.title}

+

+ {trim(lead.excerpt || lead.body, 280)} +

+
+ {lead.author ? {lead.author} : null} + {lead.href ? ( + + Read the story +
+
+
+
+ + {rest.length > 0 ? ( +
+ {rest.map((post) => ( +
+
+ {post.image ? ( + {post.title + ) : ( +
+
+ )} +
+
+ {post.category ? {post.category} : null} +

{post.title}

+

+ {trim(post.excerpt || post.body, 160)} +

+
+ {post.author} + {post.href ? ( + +
+
+
+ ))} +
+ ) : null} +
+
+ ) +}