Skip to content

Commit 6060a82

Browse files
committed
Refactor Docs Navigation buttons.
1 parent b4555c5 commit 6060a82

File tree

2 files changed

+54
-34
lines changed

2 files changed

+54
-34
lines changed

app/docs/[...slug]/page.tsx

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import path from "path";
33

44
import matter from "gray-matter";
55
import type { Metadata } from "next";
6-
import Link from "next/link";
76
import { notFound } from "next/navigation";
87
import { MDXRemote } from "next-mdx-remote/rsc";
98
import { Suspense, cache } from "react";
109

11-
import { components, mdxOptions } from "@/components/mdx/mdx-components";
1210
import { DocsHeader } from "@/components/docs/content/DocsHeader";
11+
import { DocsNavigation } from "@/components/docs/content/DocsNavigation";
1312
import { EditOnGitHub } from "@/components/docs/content/EditOnGitHub";
1413
import { ErrorBoundary } from "@/components/docs/content/ErrorBoundary";
1514
import { ReadingTime } from "@/components/docs/content/ReadingTime";
1615
import { ShortLink } from "@/components/docs/content/ShortLink";
1716
import { docsStructure } from "@/components/docs/sidebar/sidebar-structure";
17+
import { components, mdxOptions } from "@/components/mdx/mdx-components";
1818

1919
interface DocMeta {
2020
title: string;
@@ -177,38 +177,7 @@ export default async function DocPage({ params }: Props) {
177177
</ErrorBoundary>
178178
</article>
179179

180-
<div className="mx-auto mt-12 flex w-full max-w-5xl items-center justify-between gap-2">
181-
{prev ? (
182-
<Link
183-
href={prev.path}
184-
className="group flex items-center gap-1 text-sm font-normal text-gray-500 transition-colors hover:text-gray-700"
185-
prefetch={true}
186-
aria-label={`Previous: ${prev.title}`}
187-
>
188-
<span className="inline-block align-middle transition-transform group-hover:-translate-x-0.5">
189-
&#8592;
190-
</span>
191-
<span className="truncate">{prev.title}</span>
192-
</Link>
193-
) : (
194-
<div />
195-
)}
196-
{next ? (
197-
<Link
198-
href={next.path}
199-
className="group flex items-center justify-end gap-1 text-sm font-normal text-gray-500 transition-colors hover:text-gray-700"
200-
prefetch={true}
201-
aria-label={`Next: ${next.title}`}
202-
>
203-
<span className="truncate">{next.title}</span>
204-
<span className="inline-block align-middle transition-transform group-hover:translate-x-0.5">
205-
&#8594;
206-
</span>
207-
</Link>
208-
) : (
209-
<div />
210-
)}
211-
</div>
180+
<DocsNavigation prev={prev} next={next} />
212181
</div>
213182
);
214183
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"use client";
2+
3+
import { ArrowLeft, ArrowRight } from "lucide-react";
4+
import Link from "next/link";
5+
6+
interface NavigationLink {
7+
title: string;
8+
path: string;
9+
}
10+
11+
interface DocsNavigationProps {
12+
prev: NavigationLink | null;
13+
next: NavigationLink | null;
14+
}
15+
16+
export function DocsNavigation({ prev, next }: DocsNavigationProps) {
17+
return (
18+
<nav
19+
className="mx-auto mt-12 flex w-full max-w-5xl items-center justify-between gap-4"
20+
aria-label="Documentation navigation"
21+
>
22+
{prev ? (
23+
<Link
24+
href={prev.path}
25+
prefetch
26+
aria-label={`Previous: ${prev.title}`}
27+
className="group flex items-center gap-3 rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm transition hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
28+
>
29+
<ArrowLeft className="h-5 w-5 shrink-0 text-gray-500 transition group-hover:text-gray-700 dark:text-gray-400 dark:group-hover:text-gray-200" />
30+
<span className="truncate text-sm font-medium">{prev.title}</span>
31+
</Link>
32+
) : (
33+
<div />
34+
)}
35+
36+
{next ? (
37+
<Link
38+
href={next.path}
39+
prefetch
40+
aria-label={`Next: ${next.title}`}
41+
className="group flex items-center gap-3 rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm transition hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
42+
>
43+
<span className="truncate text-sm font-medium">{next.title}</span>
44+
<ArrowRight className="h-5 w-5 shrink-0 text-gray-500 transition group-hover:text-gray-700 dark:text-gray-400 dark:group-hover:text-gray-200" />
45+
</Link>
46+
) : (
47+
<div />
48+
)}
49+
</nav>
50+
);
51+
}

0 commit comments

Comments
 (0)