chore: shorten pagination

This commit is contained in:
Stefan Imhoff
2023-05-21 09:38:06 +02:00
parent 6ddae638ac
commit 11c497c6bd
2 changed files with 14 additions and 14 deletions

View File

@@ -17,14 +17,14 @@ export async function getStaticPaths() {
params: { slug: entry.slug },
props: {
entry,
nextPost:
next:
index + 1 === numberOfPages ? { slug: null, data: null } : haikuEntries[index + 1],
prevPost: index === 0 ? {} : haikuEntries[index - 1],
prev: index === 0 ? {} : haikuEntries[index - 1],
},
}));
}
const { entry, prevPost, nextPost } = Astro.props;
const { entry, prev, next } = Astro.props;
---
<BaseLayout title={`Haiku ${entry.slug}`} header={false} footer={false}>
@@ -54,9 +54,9 @@ const { entry, prevPost, nextPost } = Astro.props;
</div>
</div>
<Pagination
nextText={`Haiku ${nextPost.slug}`}
nextUrl={nextPost.slug && `/haiku/${nextPost.slug}`}
previousText={`Haiku ${prevPost.slug}`}
previousUrl={prevPost.slug && `/haiku/${prevPost.slug}`}
nextText={`Haiku ${next.slug}`}
nextUrl={next.slug && `/haiku/${next.slug}`}
previousText={`Haiku ${prev.slug}`}
previousUrl={prev.slug && `/haiku/${prev.slug}`}
/>
</BaseLayout>

View File

@@ -20,16 +20,16 @@ export async function getStaticPaths() {
params: { slug: entry.slug },
props: {
entry,
nextPost:
next:
index + 1 === numberOfPages
? { slug: null, data: null }
: projectEntries[index + 1],
prevPost: index === 0 ? {} : projectEntries[index - 1],
prev: index === 0 ? {} : projectEntries[index - 1],
},
}));
}
const { entry, prevPost, nextPost } = Astro.props;
const { entry, prev, next } = Astro.props;
const { Content } = await entry.render();
---
@@ -48,9 +48,9 @@ const { Content } = await entry.render();
</article>
<Pagination
nextText={nextPost.data?.title}
nextUrl={nextPost.slug && `/projects/${nextPost.slug}`}
previousText={prevPost.data?.title}
previousUrl={prevPost.slug && `/projects/${prevPost.slug}`}
nextText={next.data?.title}
nextUrl={next.slug && `/projects/${next.slug}`}
previousText={prev.data?.title}
previousUrl={prev.slug && `/projects/${prev.slug}`}
/>
</GridLayout>