// Archive is legacy/test data only — not part of the live signal stack.
// noindex keeps it out of search results (duplicate/thin content risk)
// while keeping it accessible to logged-in users for inspection.
export const revalidate = 60  // archive data rarely changes — ISR at 60s keeps server load low
import type { Metadata } from 'next'
import { type PostListResponse } from '@/lib/api'
import { getPosts } from '@/lib/api'
import { buildArchiveFallbackResponse, getInitialPostPage } from '@/lib/postPage'
import ArchivePageClient from './ArchivePageClient'

export const metadata: Metadata = {
  robots: { index: false, follow: false },
}

export default async function ArchivePage() {
  const initialData: PostListResponse | null = await getInitialPostPage(30, 1, {
    filters: { archiveOnly: true },
    legacyFallback: async () => {
      const legacyItems = await getPosts(500, 1).catch(() => null)
      return legacyItems ? buildArchiveFallbackResponse(legacyItems, 1, 30) : null
    },
  })

  return <ArchivePageClient initialData={initialData} />
}
