diff --git a/src/pages/blog.astro b/src/pages/blog.astro index d86c7c7..aa3d3ea 100644 --- a/src/pages/blog.astro +++ b/src/pages/blog.astro @@ -2,18 +2,14 @@ import PageShell from '../components/PageShell.astro'; import { getCollection } from 'astro:content'; -export async function getStaticPaths({ paginate }) { - const posts = (await getCollection('blog', ({ data }) => !data.draft)).sort( - (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(), - ); +const POSTS_PER_PAGE = 12; - return paginate(posts, { pageSize: 12 }); -} - -const { page } = Astro.props; +const posts = (await getCollection('blog', ({ data }) => !data.draft)).sort( + (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(), +); // Collect all unique categories -const allCategories = [...new Set(page.data.map((p) => p.data.category))].sort(); +const allCategories = [...new Set(posts.map((p) => p.data.category))].sort(); --- p.data.category))].sort()
- {page.data.map((post) => { + {posts.map((post) => { const fmt = new Intl.DateTimeFormat('th-TH', { day: '2-digit', month: 'short', year: '2-digit' }).format(post.data.pubDate); return ( @@ -59,32 +55,83 @@ const allCategories = [...new Set(page.data.map((p) => p.data.category))].sort() - {page.lastPage > 1 && ( - - )} + + + - -