24 lines
697 B
Plaintext
24 lines
697 B
Plaintext
---
|
|
import Layout from "@/layouts/Layout.astro";
|
|
import IndexView from "@/components/IndexView.astro";
|
|
import type {Post, CategoriesStats} from "@/types/post";
|
|
import {createHttp} from "@/lib/request";
|
|
import {metadata} from "@/consts.ts";
|
|
|
|
const http = createHttp(Astro.request.headers)
|
|
|
|
const {list, total} = await http.get<ApiPageResponse<Post>>("post", {
|
|
searchParams: {
|
|
page: 1,
|
|
page_size: metadata.postPageSize
|
|
}
|
|
});
|
|
const totalPage = Math.ceil(total / metadata.postPageSize)
|
|
|
|
const {data: categories} = await http.get<ApiPageResponse<CategoriesStats>>("category/stats");
|
|
---
|
|
|
|
<Layout>
|
|
<IndexView categories={categories} posts={list} page={1} totalPage={totalPage}/>
|
|
</Layout>
|