---
import BlogCard from '@/components/BlogCard.astro'
import Link from '@/components/Link.astro'
import PageHead from '@/components/PageHead.astro'
import { buttonVariants } from '@/components/ui/button'
import { SITE } from '@/consts'
import Layout from '@/layouts/Layout.astro'
import { getRecentPosts } from '@/lib/data-utils'

const blog = await getRecentPosts(SITE.featuredPostCount)
---

<Layout class="max-w-3xl">
  <PageHead slot="head" title="Home" />
  <section class="rounded-lg border">
    <div class="flex flex-col space-y-1.5 p-6">
      <h3 class="text-3xl leading-none font-medium">溴化锂</h3>
      <p class="text-muted-foreground text-sm">LiBr</p>
    </div>
    <div class="p-6 pt-0">
      <p class="text-muted-foreground mb-2 text-sm">
        nameless cybersecurity researcher. always studying.
        <br />
        More about me <Link href="/about" underline>here</Link>.
      </p>
    </div>
  </section>
  <section class="flex flex-col gap-y-4">
    <h2 class="text-2xl font-medium">Latest posts</h2>
    <ul class="flex flex-col gap-y-4">
      {
        blog.map((post) => (
          <li>
            <BlogCard entry={post} />
          </li>
        ))
      }
    </ul>
    <div class="flex justify-center">
      <Link
        href="/blog"
        class={buttonVariants({ variant: 'ghost' }) + ' group'}
      >
        See all posts <span
          class="ml-1.5 transition-transform group-hover:translate-x-1"
          >&rarr;</span
        >
      </Link>
    </div>
  </section>
</Layout>
