11import type { Metadata } from 'next' ;
22import { DocsLayout } from 'fumadocs-ui/layouts/docs' ;
3- import { HomeLayout } from 'fumadocs-ui/layouts/home' ;
43import { DocsPage , DocsBody } from 'fumadocs-ui/page' ;
54import { notFound } from 'next/navigation' ;
6- import { source , mainSource , developmentSource , selfHostedSource } from '@/lib/source' ;
5+ import { source } from '@/lib/source' ;
76import { generatePageMetadata , getCanonicalUrl } from '@/lib/seo-utils' ;
87import { getFinalPageTitle } from '@/lib/h1-extractor' ;
98import { readFile } from 'fs/promises' ;
109import { getMDXComponents } from '@/mdx-components' ;
11- import { homeOptions , docsOptions } from '../layout.config' ;
10+ import { docsOptions } from '../layout.config' ;
11+ import { generateTechArticleSchema , generateBreadcrumbSchema , combineSchemas } from '@/lib/structured-data' ;
1212
1313export default async function Page ( {
1414 params,
@@ -24,53 +24,65 @@ export default async function Page({
2424
2525 const MDX = page . data . body ;
2626
27- // Determine if this is the root page (no sidebar needed)
28- const isRootPage = ! slug || slug . length === 0 ;
27+ // Generate structured data for all pages with content
28+ let structuredData = '' ;
29+ if ( slug && slug . length > 0 ) {
30+ const slugString = slug . join ( '/' ) ;
31+ const url = `https://deploystack.io/docs/${ slugString } ` ;
32+
33+ // Get the final title (same logic as in generateMetadata)
34+ let finalTitle = page . data . title ;
35+ try {
36+ const filePath = page . file . path ;
37+ const absolutePath = `./docs/${ filePath } ` ;
38+ const rawContent = await readFile ( absolutePath , 'utf-8' ) ;
39+ finalTitle = getFinalPageTitle ( rawContent , page . data . title ) ;
40+ } catch ( error ) {
41+ finalTitle = page . data . title ;
42+ }
2943
30- // Use HomeLayout for root page (no sidebar), DocsLayout for all other pages
31- if ( isRootPage ) {
32- return (
33- < HomeLayout { ...homeOptions } >
34- < div className = "container max-w-6xl mx-auto px-4 py-8" >
35- < article className = "prose prose-neutral dark:prose-invert max-w-none" >
36- < MDX components = { getMDXComponents ( ) } />
37- </ article >
38- </ div >
39- </ HomeLayout >
40- ) ;
44+ const articleSchema = generateTechArticleSchema ( {
45+ title : finalTitle ,
46+ description : page . data . description ,
47+ slug,
48+ url,
49+ } ) ;
50+
51+ const breadcrumbSchema = generateBreadcrumbSchema ( slug ) ;
52+ structuredData = combineSchemas ( articleSchema , breadcrumbSchema ) ;
4153 }
4254
43- // Determine which section we're in and get the appropriate page tree
44- const firstSegment = slug [ 0 ] ;
45- let pageTree = mainSource . pageTree ;
46- let navTitle = 'DeployStack Docs' ;
47-
48- if ( firstSegment === 'development' ) {
49- pageTree = developmentSource . pageTree ;
50- navTitle = 'Development Docs' ;
51- } else if ( firstSegment === 'self-hosted' ) {
52- pageTree = selfHostedSource . pageTree ;
53- navTitle = 'Self-Hosted Docs' ;
54- }
55+ // Always use the unified source pageTree that includes all sections
56+ // Instead of switching between different trees, show all sections together
57+ const pageTree = source . pageTree ;
5558
59+ // Always use DocsLayout with sidebar for all pages including root
5660 return (
57- < DocsLayout
58- { ...docsOptions }
59- tree = { pageTree }
60- nav = { {
61- title : navTitle ,
62- url : '/' ,
63- } }
64- sidebar = { {
65- defaultOpenLevel : 1
66- } }
67- >
68- < DocsPage toc = { page . data . toc } full = { page . data . full } >
69- < DocsBody >
70- < MDX components = { getMDXComponents ( ) } />
71- </ DocsBody >
72- </ DocsPage >
73- </ DocsLayout >
61+ < >
62+ { structuredData && (
63+ < script
64+ type = "application/ld+json"
65+ dangerouslySetInnerHTML = { { __html : structuredData } }
66+ />
67+ ) }
68+ < DocsLayout
69+ { ...docsOptions }
70+ tree = { pageTree }
71+ nav = { {
72+ title : 'DeployStack Docs' ,
73+ url : '/' ,
74+ } }
75+ sidebar = { {
76+ defaultOpenLevel : 1
77+ } }
78+ >
79+ < DocsPage toc = { page . data . toc } full = { page . data . full } >
80+ < DocsBody >
81+ < MDX components = { getMDXComponents ( ) } />
82+ </ DocsBody >
83+ </ DocsPage >
84+ </ DocsLayout >
85+ </ >
7486 ) ;
7587}
7688
0 commit comments