mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
18 lines
542 B
Plaintext
18 lines
542 B
Plaintext
---
|
|
import { SITE } from "src/config";
|
|
import Posts from "@layouts/Posts.astro";
|
|
import getSortedPosts from "@utils/getSortedPosts";
|
|
import getPageNumbers from "@utils/getPageNumbers";
|
|
import type { Frontmatter } from "src/types";
|
|
|
|
const posts = await Astro.glob<Frontmatter>("../../contents/**/*.md");
|
|
|
|
const sortedPosts = getSortedPosts(posts);
|
|
|
|
const totalPages = getPageNumbers(posts.length);
|
|
|
|
const paginatedPosts = sortedPosts.slice(0, SITE.postPerPage);
|
|
---
|
|
|
|
<Posts posts={paginatedPosts} pageNum={1} totalPages={totalPages.length} />
|