import { getPosts } from '@/lib/posts'
import { PostSearch } from '@/components/posts/PostSearch'

export const metadata = { title: 'Field Notes' }

export default async function PostsPage() {
  const posts = await getPosts()

  return (
    <>
      <header className="mb-10 border-b border-border pb-8">
        <p className="section-label mb-4">FIELD NOTES /.06</p>
        <h1 className="heading-xl m-0 text-ink">
          Field Notes
        </h1>
      </header>

      {posts.length > 0 ? (
        <PostSearch posts={posts} />
      ) : (
        <section className="empty-state" aria-label="No posts published">
          <p className="m-0 text-sm leading-6 text-ink-soft">Archive empty.</p>
        </section>
      )}
    </>
  )
}
