---
import FullLayoutV1 from '../layout/FullLayoutV1.astro'
import { listBlogs } from '../lib/apis/legacy/blog'

export const prerender = false

const _page = parseInt(Astro.url.searchParams.get('page') || '1')
const page = isNaN(_page) ? 1 : Math.max(1, _page)

const blogs = await listBlogs({ page })
---

<FullLayoutV1 withGap>
  <!-- <div class="__dev__caution">
    <h1>仍在开发中，界面会崩坏</h1>
  </div> -->
  <main>
    <ul>
      {
        blogs.map((blog) => (
          <li>
            <a href={`/blogs/${blog.id}`}>{blog.title}</a>
          </li>
        ))
      }
    </ul>
  </main>
</FullLayoutV1>

<style>
  .__dev__caution {
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;

    & > h1 {
      font-size: 72px;
      font-weight: 800;
    }
  }

  main {
  }
</style>
