aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/Pagination.astro35
-rw-r--r--src/pages/[...page].astro33
-rw-r--r--src/pages/index.astro17
3 files changed, 17 insertions, 68 deletions
diff --git a/src/components/Pagination.astro b/src/components/Pagination.astro
deleted file mode 100644
index 0d656df..0000000
--- a/src/components/Pagination.astro
+++ /dev/null
@@ -1,35 +0,0 @@
----
-type Props = {
- readonly nextUrl?: string;
- readonly prevUrl?: string;
-};
-
-const { nextUrl, prevUrl } = Astro.props;
----
-
-<style lang="scss">
- div {
- text-align: center;
- }
-
- span {
- margin: 0 2em;
- }
-</style>
-
-<div>
- {
- prevUrl && (
- <span>
- <a href={prevUrl}>&lt; Prev</a>
- </span>
- )
- }
- {
- nextUrl && (
- <span>
- <a href={nextUrl}>Next &gt;</a>
- </span>
- )
- }
-</div>
diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro
deleted file mode 100644
index 6d513b2..0000000
--- a/src/pages/[...page].astro
+++ /dev/null
@@ -1,33 +0,0 @@
----
-import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
-import { getCollection } from "astro:content";
-import Layout from "../layouts/BaseLayout.astro";
-import Pagination from "../components/Pagination.astro";
-import PostSummary from "../components/PostSummary.astro";
-
-type Props = InferGetStaticPropsType<typeof getStaticPaths>;
-
-export const getStaticPaths = (async ({ paginate }) => {
- const posts = await getCollection("blog", ({ data }) => {
- return data.draft !== true;
- });
-
- posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
-
- return paginate(posts, {
- pageSize: 10,
- });
-}) satisfies GetStaticPaths;
-
-const { page } = Astro.props;
----
-
-<Layout>
- <section style={{ "margin-top": "3rem" }}>
- {page.data.map((post) => <PostSummary post={post} />)}
- </section>
-
- <section>
- <Pagination nextUrl={page.url.next} prevUrl={page.url.prev} />
- </section>
-</Layout>
diff --git a/src/pages/index.astro b/src/pages/index.astro
new file mode 100644
index 0000000..56ccdff
--- /dev/null
+++ b/src/pages/index.astro
@@ -0,0 +1,17 @@
+---
+import { getCollection } from "astro:content";
+import Layout from "../layouts/BaseLayout.astro";
+import PostSummary from "../components/PostSummary.astro";
+
+const posts = await getCollection("blog", ({ data }) => {
+ return data.draft !== true;
+});
+
+posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
+---
+
+<Layout>
+ <section style={{ "margin-top": "3rem" }}>
+ {posts.map((post) => <PostSummary post={post} />)}
+ </section>
+</Layout>