aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-09-13 03:26:08 +0300
committerValentin Popov <valentin@popov.link>2024-09-13 03:26:08 +0300
commit5217bcb24ceac2e7d441586edc56feba60b482a9 (patch)
tree9e8f10a6183fc19daa94dcc798567a23b7b641a1
parent4a821edd509151769ad0a67ac520653ae374f73c (diff)
downloadpopov.link-5217bcb24ceac2e7d441586edc56feba60b482a9.tar.xz
popov.link-5217bcb24ceac2e7d441586edc56feba60b482a9.zip
Refactor Pagination component to update page size in getStaticPaths
-rw-r--r--src/components/Pagination.astro27
-rw-r--r--src/components/Pagination/Next.astro18
-rw-r--r--src/components/Pagination/Prev.astro18
-rw-r--r--src/pages/[...page].astro2
4 files changed, 20 insertions, 45 deletions
diff --git a/src/components/Pagination.astro b/src/components/Pagination.astro
index 835ea2d..0d656df 100644
--- a/src/components/Pagination.astro
+++ b/src/components/Pagination.astro
@@ -1,7 +1,4 @@
---
-import Next from "./Pagination/Next.astro";
-import Prev from "./Pagination/Prev.astro";
-
type Props = {
readonly nextUrl?: string;
readonly prevUrl?: string;
@@ -12,13 +9,27 @@ const { nextUrl, prevUrl } = Astro.props;
<style lang="scss">
div {
- overflow: hidden;
- padding: 3rem 0;
- width: 100%;
+ text-align: center;
+ }
+
+ span {
+ margin: 0 2em;
}
</style>
<div>
- {prevUrl && <Prev url={prevUrl} />}
- {nextUrl && <Next url={nextUrl} />}
+ {
+ prevUrl && (
+ <span>
+ <a href={prevUrl}>&lt; Prev</a>
+ </span>
+ )
+ }
+ {
+ nextUrl && (
+ <span>
+ <a href={nextUrl}>Next &gt;</a>
+ </span>
+ )
+ }
</div>
diff --git a/src/components/Pagination/Next.astro b/src/components/Pagination/Next.astro
deleted file mode 100644
index 1a95710..0000000
--- a/src/components/Pagination/Next.astro
+++ /dev/null
@@ -1,18 +0,0 @@
----
-type Props = {
- readonly url: string;
-};
-
-const { url } = Astro.props;
----
-
-<style lang="scss">
- span {
- float: right;
- max-width: 40%;
- }
-</style>
-
-<span>
- <a href={url}>Next &gt;</a>
-</span>
diff --git a/src/components/Pagination/Prev.astro b/src/components/Pagination/Prev.astro
deleted file mode 100644
index 2454876..0000000
--- a/src/components/Pagination/Prev.astro
+++ /dev/null
@@ -1,18 +0,0 @@
----
-type Props = {
- readonly url: string;
-};
-
-const { url } = Astro.props;
----
-
-<style lang="scss">
- span {
- float: left;
- max-width: 40%;
- }
-</style>
-
-<span>
- <a href={url}>&lt; Prev</a>
-</span>
diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro
index 2a6f5cc..42f84b3 100644
--- a/src/pages/[...page].astro
+++ b/src/pages/[...page].astro
@@ -12,7 +12,7 @@ export const getStaticPaths = (async ({ paginate }) => {
posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
return paginate(posts, {
- pageSize: 5,
+ pageSize: 10,
});
}) satisfies GetStaticPaths;