import { metadata } from '@/app/metadata'
import { TableOfContents } from '@/components/post/TableOfContents'
import { getPostBySlug } from '@/lib/posts'
import type { Metadata } from 'next'

export async function generateMetadata(): Promise<Metadata> {
  const { meta } = await getPostBySlug('setup', 'content/pages')
  return {
    title: `${meta.title} | ${metadata.title!.toString()}`,
    description: meta.description,
    openGraph: {
      type: 'website',
      title: `${meta.title} | ${metadata.title!.toString()}`,
      description: meta.description,
      url: process.env.SITE_URL + `/setup`,
      siteName: metadata.title!.toString(),
    },
  }
}

export default async function SetupPage() {
  const { meta, content, tableOfContents } = await getPostBySlug('setup', 'content/pages')

  return (
    <main className="flex w-full">
      <article className="max-w-3xl 2xl:max-w-4xl mx-auto px-4 py-8 mb-8 lg:py-16 min-w-0">
        <h1 className="text-4xl font-bold mb-4">{meta.title}</h1>
        <p className="text-fg text-lg mb-4">{meta.description}</p>
        <div className="prose">{content}</div>
      </article>

      <TableOfContents items={tableOfContents} />
    </main>
  )
}
