From 4a44a10ad99baa835ea004935b8c276e012e61fa Mon Sep 17 00:00:00 2001 From: dreymotoh Date: Fri, 28 Jun 2024 15:17:29 -0400 Subject: [PATCH] feat: switched routing over! removed unnecessary code --- src/pages/[...page].astro | 44 +++++++++++++++++++++++++++ src/pages/index.astro | 63 --------------------------------------- 2 files changed, 44 insertions(+), 63 deletions(-) create mode 100644 src/pages/[...page].astro delete mode 100644 src/pages/index.astro diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro new file mode 100644 index 0000000..cf34aa0 --- /dev/null +++ b/src/pages/[...page].astro @@ -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; + + // 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 ?? ''; +--- + + + TorontoJS Blog + + diff --git a/src/pages/index.astro b/src/pages/index.astro deleted file mode 100644 index ee63afa..0000000 --- a/src/pages/index.astro +++ /dev/null @@ -1,63 +0,0 @@ ---- -import SiteNav from '../components/SiteNav/index.astro'; -import SkipToContent from '../components/SkipToContent/index.astro'; -import BaseLayout from '../layouts/Base/index.astro'; - -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; - -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 ?? ''; ---- - - -
- -
- - - - TorontoJS Blog - - - - -