@@ -2,6 +2,7 @@ import Link from "next/link";
22import { notFound , redirect } from 'next/navigation' ;
33import { capitalCase } from 'change-case' ;
44import { getAllArticlePaths , getArticleByPath } from "../../../services/articleService" ;
5+ import { getMetadata } from "../../../services/metadataService" ;
56import ComingSoon from "../../../components/ComingSoon" ;
67import CommandSnippet from "../../../components/CommandSnippet" ;
78import Markdown from "../../../components/Markdown" ;
@@ -48,10 +49,12 @@ export async function generateMetadata({ params }: PageProps) {
4849 const selectedNavItem = navigation . find ( ( item ) => item . link . includes ( file ) ) ;
4950 const pageTitle = frontmatter . title || selectedNavItem ?. title || section ;
5051
51- return {
52+ return getMetadata ( {
5253 title : `${ pageTitle } - DocumentDB Documentation` ,
53- description : frontmatter . description || undefined ,
54- } ;
54+ description : frontmatter . description || '' ,
55+ path : slug . length > 0 ? `/docs/${ section } /${ slug . join ( '/' ) } /` : `/docs/${ section } /` ,
56+ type : 'article' ,
57+ } ) ;
5558}
5659
5760export default async function ArticlePage ( { params } : PageProps ) {
@@ -80,6 +83,34 @@ export default async function ArticlePage({ params }: PageProps) {
8083 // Use title from frontmatter if available, otherwise fall back to navigation title or section name
8184 const pageTitle = frontmatter . title || selectedNavItem ?. title || section ;
8285 const showInstallPrimer = section === "getting-started" && file === "index" ;
86+ const sectionTitle = capitalCase ( section )
87+ . replace ( / d o c u m e n t d b / i, 'DocumentDB' )
88+ . replace ( / a p i / i, 'API' ) ;
89+
90+ // Rendered once, shown in the desktop sidebar and the mobile disclosure
91+ const navigationLinks = navigation . map ( ( item ) => {
92+ // Better matching logic for active state
93+ // For index files, match both /section and /section/index
94+ // For other files, match the specific file name
95+ const itemPath = item . link . replace ( '/docs/' , '' ) ;
96+ const currentPath = file === 'index' ? section : `${ section } /${ file } ` ;
97+ const isActive = itemPath === currentPath ||
98+ ( file === 'index' && itemPath === `${ section } /index` ) ||
99+ ( item . link . includes ( file ) && file !== 'index' ) ;
100+
101+ return (
102+ < Link
103+ key = { item . link }
104+ href = { item . link }
105+ className = { `block w-full text-left px-4 py-3 rounded-lg text-sm transition-all duration-200 ${ isActive
106+ ? "bg-blue-500/20 text-blue-300 border border-blue-500/30"
107+ : "text-gray-300 hover:text-white hover:bg-neutral-700/50"
108+ } `}
109+ >
110+ { item . title }
111+ </ Link >
112+ ) ;
113+ } ) ;
83114
84115 return (
85116 < div className = "min-h-screen bg-neutral-900 relative overflow-hidden" >
@@ -94,8 +125,8 @@ export default async function ArticlePage({ params }: PageProps) {
94125 </ div >
95126
96127 < div className = "relative flex min-h-screen" >
97- { /* Left Sidebar */ }
98- < div className = "w-80 bg-neutral-800/50 backdrop-blur-sm border-r border-neutral-700/50 flex flex-col" >
128+ { /* Left Sidebar (desktop only; mobile gets the disclosure below) */ }
129+ < div className = "hidden w-80 bg-neutral-800/50 backdrop-blur-sm border-r border-neutral-700/50 md: flex flex-col" >
99130 { /* Header */ }
100131 < div className = "p-6 border-b border-neutral-700/50" >
101132 < Link
@@ -117,48 +148,41 @@ export default async function ArticlePage({ params }: PageProps) {
117148 </ svg >
118149 Back to Documentation
119150 </ Link >
120- < h1 className = "text-2xl font-bold text-white" >
121- {
122- capitalCase ( section )
123- . replace ( / d o c u m e n t d b / i, 'DocumentDB' )
124- . replace ( / a p i / i, 'API' )
125- }
126- </ h1 >
151+ { /* Not a heading: the article's h1 comes from the markdown content */ }
152+ < p className = "text-2xl font-bold text-white" >
153+ { sectionTitle }
154+ </ p >
127155 </ div >
128156
129157 { /* Menu Items */ }
130158 < div className = "flex-1 p-4 overflow-y-auto" >
131159 < nav className = "space-y-1" >
132- { navigation . map ( ( item ) => {
133- // Better matching logic for active state
134- // For index files, match both /section and /section/index
135- // For other files, match the specific file name
136- const itemPath = item . link . replace ( '/docs/' , '' ) ;
137- const currentPath = file === 'index' ? section : `${ section } /${ file } ` ;
138- const isActive = itemPath === currentPath ||
139- ( file === 'index' && itemPath === `${ section } /index` ) ||
140- ( item . link . includes ( file ) && file !== 'index' ) ;
141-
142- return (
143- < Link
144- key = { item . link }
145- href = { item . link }
146- className = { `block w-full text-left px-4 py-3 rounded-lg text-sm transition-all duration-200 ${ isActive
147- ? "bg-blue-500/20 text-blue-300 border border-blue-500/30"
148- : "text-gray-300 hover:text-white hover:bg-neutral-700/50"
149- } `}
150- >
151- { item . title }
152- </ Link >
153- ) ;
154- } ) }
160+ { navigationLinks }
155161 </ nav >
156162 </ div >
157163 </ div >
158164
159165 { /* Main Content */ }
160- < div className = "flex-1 p-8 overflow-y-auto" >
166+ < div className = "flex-1 p-4 sm:p- 8 overflow-y-auto" >
161167 < div className = "max-w-4xl" >
168+ { /* Mobile section navigation */ }
169+ < details className = "mb-6 rounded-lg border border-neutral-700/50 bg-neutral-800/50 md:hidden" >
170+ < summary className = "cursor-pointer px-4 py-3 text-sm font-semibold text-gray-200" >
171+ { sectionTitle } navigation
172+ </ summary >
173+ < div className = "border-t border-neutral-700/50 p-3" >
174+ < Link
175+ href = "/docs"
176+ className = "block px-4 py-2 text-sm text-blue-400 hover:text-blue-300 transition-colors"
177+ >
178+ ← Back to Documentation
179+ </ Link >
180+ < nav className = "space-y-1" >
181+ { navigationLinks }
182+ </ nav >
183+ </ div >
184+ </ details >
185+
162186 { /* Coming Soon Component for coming-soon layout */ }
163187 { frontmatter . layout === 'coming-soon' && < ComingSoon /> }
164188
0 commit comments