Files
365devnet/src/pages/[...blog]/[...page].astro
2023-01-06 15:25:11 -05:00

38 lines
1.1 KiB
Plaintext

---
import { SITE, BLOG } from '~/config.mjs';
import Layout from '~/layouts/PageLayout.astro';
import BlogList from '~/components/blog/List.astro';
import Pagination from '~/components/common/Pagination.astro';
import { fetchPosts } from '~/utils/blog';
import { BLOG_BASE } from '~/utils/permalinks';
import Title from '~/components/blog/Title.astro';
export async function getStaticPaths({ paginate }) {
if (BLOG?.disabled || BLOG?.blog?.disabled) return [];
return paginate(await fetchPosts(), {
params: { blog: BLOG_BASE || undefined },
pageSize: BLOG.postsPerPage,
});
}
const { page } = Astro.props;
const currentPage = page.currentPage ?? 1;
const meta = {
title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
description: SITE.description,
noindex: BLOG?.blog?.noindex || currentPage > 1,
ogType: 'blog',
};
---
<Layout {meta}>
<section class="px-6 sm:px-6 py-12 sm:py-16 lg:py-20 mx-auto max-w-3xl">
<Title>News and tutorials about AstroWind</Title>
<BlogList posts={page.data} />
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</section>
</Layout>