Skip to content

Commit d357249

Browse files
committed
fix: incorrect previous/next path order
1 parent fab2f50 commit d357249

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

website-v3/src/components/PreviousNext.astro

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ type Anchor = [string, string];
2525
let previous: Anchor | undefined;
2626
let next: Anchor | undefined;
2727
28+
const titleForLink = (link: string) => {
29+
return links.find(([_, href]) => href === link)?.at(0) || null;
30+
};
31+
2832
// If the user has specified a previous or next page, use that.
29-
if (frontmatter.previous) previous = [frontmatter.previous, frontmatter.previousTitle];
30-
if (frontmatter.next) next = [frontmatter.next, frontmatter.nextTitle];
33+
if (frontmatter.previous)
34+
previous = [frontmatter.previousTitle || titleForLink(frontmatter.previous) || '', frontmatter.previous];
35+
if (frontmatter.next)
36+
next = [frontmatter.nextTitle || titleForLink(frontmatter.next) || '', frontmatter.next];
3137
3238
// If the user wants auto infered previous/next, find them (if not already set).
3339
if (automaticallyInferNextPrevious) {
@@ -57,7 +63,7 @@ if (automaticallyInferNextPrevious) {
5763
{!!next && (
5864
<Link
5965
href={next[1]}
60-
className="group inline-flex items-center gap-2 opacity-75 transition hover:opacity-100 text-right"
66+
className="group inline-flex items-center gap-2 text-right opacity-75 transition hover:opacity-100"
6167
>
6268
<span>{next[0]}</span>
6369
<span class="group-hover:text-docs-theme h-4 w-4 flex-shrink-0 transition">

0 commit comments

Comments
 (0)