Skip to content

Commit

Permalink
feat: switched routing over! removed unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreymoreau committed Jun 28, 2024
1 parent 2c6a424 commit 4a44a10
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 63 deletions.
44 changes: 44 additions & 0 deletions src/pages/[...page].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
import type { GetStaticPaths, InferGetStaticPropsType, PaginateFunction } from 'astro';
import { MAX_POSTS_PER_PAGE, listAllPosts } from 'src/utils/post';
import BlogPostsLayout from '../layouts/BlogPosts.astro';
// eslint-disable-next-line @typescript-eslint/no-use-before-define
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
// List of pages to compile to
export const getStaticPaths = (async ({ paginate }: { paginate: PaginateFunction }) => {
const postsList = await listAllPosts();
return paginate(postsList, {
pageSize: MAX_POSTS_PER_PAGE
});
}) satisfies GetStaticPaths;
const {
data: posts,
url,
currentPage, lastPage,
start, end, total, size
} = Astro.props.page;
const BLOG_URL = Astro.site?.href ?? '';
---
<BlogPostsLayout
posts={posts}
baseUrl={BLOG_URL}
currentUrl={url.current}
currentPage={currentPage}
lastPage={lastPage}
prevUrl={url.prev}
nextUrl={url.next}
start={start}
end={end}
total={total}
size={size}
>
<Fragment slot="header">
TorontoJS Blog
</Fragment>
</BlogPostsLayout>
63 changes: 0 additions & 63 deletions src/pages/index.astro

This file was deleted.

0 comments on commit 4a44a10

Please sign in to comment.