switch next and previous links to match chronological post order

This commit is contained in:
Joseph Montanaro 2024-11-11 10:23:38 -05:00
parent 9c35c72989
commit 2f61b4a453

View File

@ -4,7 +4,7 @@ import { postData } from '../_posts/all.js';
export function load({ params }) { export function load({ params }) {
const i = postData.findIndex(p => p.slug === params.slug); const i = postData.findIndex(p => p.slug === params.slug);
return { return {
prev: i > 0 ? postData[i - 1].slug : null, prev: i < postData.length - 1 ? postData[i + 1].slug : null,
next: i < postData.length - 1 ? postData[i + 1].slug : null, next: i > 0 ? postData[i - 1].slug : null,
}; };
} }