File tree Expand file tree Collapse file tree 4 files changed +54
-3
lines changed
Expand file tree Collapse file tree 4 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 44/cloudflare-env.d.ts
55
66# generated docs section file lists (regenerated by npm run generateDocsMeta)
7- /public /docs /** /sections.json
8- /public /docs /languages.json
7+ /public /docs /** /sections. *
8+ /public /docs /languages. *
99
1010# dependencies
1111/node_modules
Original file line number Diff line number Diff line change @@ -38,9 +38,13 @@ export default async function Page({
3838 const { lang, pageId } = await params ;
3939 const pagesList = await getPagesList ( ) ;
4040 const langEntry = pagesList . find ( ( l ) => l . id === lang ) ;
41- const pageEntry = langEntry ?. pages . find ( ( p ) => p . slug === pageId ) ;
41+ const pageEntryIndex = langEntry ?. pages . findIndex ( ( p ) => p . slug === pageId ) ?? - 1 ;
42+ const pageEntry = langEntry ?. pages [ pageEntryIndex ] ;
4243 if ( ! langEntry || ! pageEntry ) notFound ( ) ;
4344
45+ const prevPage = langEntry . pages [ pageEntryIndex - 1 ] ;
46+ const nextPage = langEntry . pages [ pageEntryIndex + 1 ] ;
47+
4448 // server componentなのでuseMemoいらない
4549 const path = { lang : lang , page : pageId } ;
4650 const sections = await getMarkdownSections ( lang , pageId ) ;
@@ -57,6 +61,8 @@ export default async function Page({
5761 splitMdContent = { sections }
5862 langEntry = { langEntry }
5963 pageEntry = { pageEntry }
64+ prevPage = { prevPage }
65+ nextPage = { nextPage }
6066 path = { path }
6167 />
6268 </ ChatHistoryProvider >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { Heading, StyledMarkdown } from "./markdown";
66import { useChatHistoryContext } from "./chatHistory" ;
77import { useSidebarMdContext } from "@/sidebar" ;
88import clsx from "clsx" ;
9+ import { PageTransition } from "./pageTransition" ;
910import {
1011 LanguageEntry ,
1112 MarkdownSection ,
@@ -22,6 +23,8 @@ interface PageContentProps {
2223 splitMdContent : MarkdownSection [ ] ;
2324 langEntry : LanguageEntry ;
2425 pageEntry : PageEntry ;
26+ prevPage ?: PageEntry ;
27+ nextPage ?: PageEntry ;
2528 path : PagePath ;
2629}
2730export function PageContent ( props : PageContentProps ) {
@@ -149,6 +152,11 @@ export function PageContent(props: PageContentProps) {
149152 </ div >
150153 </ Fragment >
151154 ) ) }
155+ < PageTransition
156+ lang = { path . lang }
157+ prevPage = { props . prevPage }
158+ nextPage = { props . nextPage }
159+ />
152160 { isFormVisible ? (
153161 // sidebarの幅が80であることからleft-84 (sidebar.tsx参照)
154162 // replがz-10を使用することからそれの上にするためz-20
Original file line number Diff line number Diff line change 1+ import Link from "next/link" ;
2+ import { LangId , PageEntry } from "@/lib/docs" ;
3+
4+ interface PageTransitionProps {
5+ lang : LangId ;
6+ prevPage ?: PageEntry ;
7+ nextPage ?: PageEntry ;
8+ }
9+
10+ export function PageTransition ( { lang, prevPage, nextPage } : PageTransitionProps ) {
11+ return (
12+ < div className = "flex justify-between gap-4 mt-12 pt-8 border-t border-base-content/10 min-w-1/2 max-w-200 col-span-2" >
13+ < div className = "flex-1 flex" >
14+ { prevPage && (
15+ < Link
16+ href = { `/${ lang } /${ prevPage . slug } ` }
17+ className = "group flex-1 btn btn-ghost border-2 border-base-content/20 hover:border-primary flex flex-col items-start h-auto py-2 normal-case text-left"
18+ >
19+ < span className = "text-xs text-base-content/60 font-normal group-hover:text-primary" > 前のページ</ span >
20+ < span className = "text-sm md:text-base group-hover:text-primary" > « { prevPage . name } </ span >
21+ </ Link >
22+ ) }
23+ </ div >
24+ < div className = "flex-1 flex" >
25+ { nextPage && (
26+ < Link
27+ href = { `/${ lang } /${ nextPage . slug } ` }
28+ className = "group flex-1 btn btn-ghost border-2 border-base-content/20 hover:border-primary flex flex-col items-end h-auto py-2 normal-case text-right"
29+ >
30+ < span className = "text-xs text-base-content/60 font-normal group-hover:text-primary" > 次のページ</ span >
31+ < span className = "text-sm md:text-base group-hover:text-primary" > { nextPage . name } »</ span >
32+ </ Link >
33+ ) }
34+ </ div >
35+ </ div >
36+ ) ;
37+ }
You can’t perform that action at this time.
0 commit comments