Skip to content

Commit 709fb03

Browse files
committed
Refactor
1 parent b742947 commit 709fb03

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/components/DocsFooter.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,37 @@ function areEqual(prevProps: DocsPageFooterProps, props: DocsPageFooterProps) {
1919

2020
export const DocsPageFooter = memo<DocsPageFooterProps>(
2121
function DocsPageFooter({nextRoute, prevRoute, route}) {
22-
if (!route || route?.heading) {
22+
if (!route || route?.heading || !route.path || route.path === '/blog') {
2323
return null;
2424
}
2525

26+
let next;
27+
let prev;
28+
if (route.path.indexOf('/blog') === 0) {
29+
next = prevRoute;
30+
prev = nextRoute;
31+
} else {
32+
next = nextRoute;
33+
prev = prevRoute;
34+
}
35+
2636
return (
2737
<>
28-
{prevRoute?.path || nextRoute?.path ? (
38+
{prev?.path || next?.path ? (
2939
<>
3040
<div className="grid grid-cols-1 gap-4 py-4 mx-auto max-w-7xl md:grid-cols-2 md:py-12">
31-
{prevRoute?.path ? (
41+
{prev?.path ? (
3242
<FooterLink
3343
type="Previous"
34-
title={prevRoute.title}
35-
href={prevRoute.path}
44+
title={prev.title}
45+
href={prev.path}
3646
/>
3747
) : (
3848
<div />
3949
)}
4050

41-
{nextRoute?.path ? (
42-
<FooterLink
43-
type="Next"
44-
title={nextRoute.title}
45-
href={nextRoute.path}
46-
/>
51+
{next?.path && next.path !== '/blog' ? (
52+
<FooterLink type="Next" title={next.title} href={next.path} />
4753
) : (
4854
<div />
4955
)}

src/components/Layout/Page.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ export function Page({
5252
cleanedPath,
5353
routeTree
5454
);
55-
const getNavigationRoutes = () => {
56-
if (section !== 'blog') return { nextRoute, prevRoute };
57-
return { nextRoute: prevRoute, prevRoute: nextRoute }; // Swap for blog
58-
};
5955

60-
const { nextRoute: finalNextRoute, prevRoute: finalPrevRoute } = getNavigationRoutes();
6156
const title = meta.title || route?.title || '';
6257
const version = meta.version;
6358
const description = meta.description || route?.description || '';
@@ -92,13 +87,11 @@ export function Page({
9287
<LanguagesContext value={languages}>{children}</LanguagesContext>
9388
</TocContext>
9489
</div>
95-
{!isBlogIndex && (
96-
<DocsPageFooter
97-
route={route}
98-
nextRoute={finalNextRoute}
99-
prevRoute={finalPrevRoute}
100-
/>
101-
)}
90+
<DocsPageFooter
91+
route={route}
92+
nextRoute={nextRoute}
93+
prevRoute={prevRoute}
94+
/>
10295
</div>
10396
</div>
10497
);

0 commit comments

Comments
 (0)