Skip to content

Fix: Correct blog post navigation order #7850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/components/DocsFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,37 @@ function areEqual(prevProps: DocsPageFooterProps, props: DocsPageFooterProps) {

export const DocsPageFooter = memo<DocsPageFooterProps>(
function DocsPageFooter({nextRoute, prevRoute, route}) {
if (!route || route?.heading) {
if (!route || route?.heading || !route.path || route.path === '/blog') {
return null;
}

let next;
let prev;
if (route.path.indexOf('/blog') === 0) {
next = prevRoute;
prev = nextRoute;
} else {
next = nextRoute;
prev = prevRoute;
}

return (
<>
{prevRoute?.path || nextRoute?.path ? (
{prev?.path || next?.path ? (
<>
<div className="grid grid-cols-1 gap-4 py-4 mx-auto max-w-7xl md:grid-cols-2 md:py-12">
{prevRoute?.path ? (
{prev?.path ? (
<FooterLink
type="Previous"
title={prevRoute.title}
href={prevRoute.path}
title={prev.title}
href={prev.path}
/>
) : (
<div />
)}

{nextRoute?.path ? (
<FooterLink
type="Next"
title={nextRoute.title}
href={nextRoute.path}
/>
{next?.path && next.path !== '/blog' ? (
<FooterLink type="Next" title={next.title} href={next.path} />
) : (
<div />
)}
Expand Down
13 changes: 6 additions & 7 deletions src/components/Layout/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function Page({
cleanedPath,
routeTree
);

const title = meta.title || route?.title || '';
const version = meta.version;
const description = meta.description || route?.description || '';
Expand Down Expand Up @@ -86,13 +87,11 @@ export function Page({
<LanguagesContext value={languages}>{children}</LanguagesContext>
</TocContext>
</div>
{!isBlogIndex && (
<DocsPageFooter
route={route}
nextRoute={nextRoute}
prevRoute={prevRoute}
/>
)}
<DocsPageFooter
route={route}
nextRoute={nextRoute}
prevRoute={prevRoute}
/>
</div>
</div>
);
Expand Down