import { postsQuery, urlFor } from '@/lib/sanity' import { sanityFetch } from '@/lib/sanityFetch' import Link from 'next/link' import Image from 'next/image' import type { Metadata } from 'next' export const metadata: Metadata = { title: 'Build Guides', description: 'AR-15 build guides, part breakdowns, and buying advice from Battl Builders.', } export const revalidate = 60 // ISR — regenerate every 60s type Post = { _id: string title: string slug: { current: string } publishedAt: string excerpt: string | null mainImage: { asset: object; alt?: string } | null author: { name: string; image?: object } | null } function formatDate(iso: string) { return new Date(iso).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric', }) } export default async function GuidesPage() { let posts: Post[] = [] try { posts = await sanityFetch(postsQuery) } catch (err) { console.error('[Guides] Sanity fetch failed:', err) } return (

Battl Builders

Build Guides

Part breakdowns, buying advice, and build walkthroughs to help you make smarter decisions before you spend a dollar.

{posts.length === 0 ? (

No guides published yet — check back soon.

) : (
{posts.map((post) => (
{/* Thumbnail */} {post.mainImage?.asset && (
{post.mainImage.alt
)} {/* Text */}
{post.author?.name && {post.author.name}} {post.author?.name && ·}

{post.title}

{post.excerpt && (

{post.excerpt}

)} Read guide →
))}
)}

Ready to start building?{' '} Open the Builder →

) }