@@ -4,7 +4,7 @@ import Layout from '~/layouts/Layout.astro'
44import { SeriesGroup , TagsGroup , getSortedPosts } from ' ~/utils'
55import PostPreview from ' ~/components/PostPreview.astro'
66import DividerText from ' ~/components/DividerText.astro'
7- import { getCollection , render } from ' astro:content'
7+ import { getCollection , render , type CollectionEntry } from ' astro:content'
88import PostAddendum from ' ~/components/PostAddendum.astro'
99import TableOfContents from ' ~/components/TableOfContents.astro'
1010import { Image } from ' astro:assets'
@@ -14,6 +14,7 @@ import Tags from '~/components/Tags.astro'
1414import PostInfo from ' ~/components/PostInfo.astro'
1515import ScrollUpButton from ' ~/components/ScrollUpButton.astro'
1616import type { Collation } from ' ~/types'
17+ import ChevronsRight from ' ~/icons/chevrons-right.svg'
1718
1819export const getStaticPaths = (async () => {
1920 const posts = await getSortedPosts ()
@@ -46,9 +47,18 @@ const sortedPosts = await getSortedPosts()
4647
4748// Get series posts if this post is part of a series
4849let series: Collation <' posts' > | undefined
50+ let nextPostInSeries: CollectionEntry <' posts' > | undefined
4951if (postData .series ) {
5052 const seriesGroup = await SeriesGroup .build (sortedPosts )
5153 series = seriesGroup .match (postData .series )
54+ if (! series ) {
55+ // This should not happen if series data is correct
56+ throw new Error (` Series "${postData .series }" not found ` )
57+ }
58+ const index = series .entries .findIndex ((entry ) => entry .id === post .id )
59+ if (index >= 0 && index <= series .entries .length - 2 ) {
60+ nextPostInSeries = series .entries [index + 1 ]
61+ }
5262}
5363const showSeries = series && series .entries .length > 1
5464
@@ -100,7 +110,17 @@ if (postData.tags && postData.tags.length > 0) {
100110 </div >
101111 </div >
102112 </article >
103- <div class =" article-end-marker" aria-hidden =" true" ></div >
113+ {
114+ nextPostInSeries && (
115+ <a
116+ href = { ` /posts/${nextPostInSeries .id } ` }
117+ class = " button justify-center -mt-8 mb-8 !whitespace-normal text-center flex gap-2 sm:gap-3 items-center"
118+ >
119+ <span >Next: { nextPostInSeries .data .title } </span >
120+ <ChevronsRight class = " size-5 hidden sm:block" />
121+ </a >
122+ )
123+ }
104124 {
105125 AddendumContent && (
106126 <PostAddendum avatarImage = { addendumAvatarImage } >
0 commit comments