Skip to content

Commit fff6dda

Browse files
authored
Merge pull request #189 from deploystackio/feat/imp2
Feat/imp2
2 parents ab8fa2a + 0262ac0 commit fff6dda

24 files changed

+1474
-426
lines changed

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

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { Metadata } from 'next';
22
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
3-
import { HomeLayout } from 'fumadocs-ui/layouts/home';
43
import { DocsPage, DocsBody } from 'fumadocs-ui/page';
54
import { notFound } from 'next/navigation';
6-
import { source, mainSource, developmentSource, selfHostedSource } from '@/lib/source';
5+
import { source } from '@/lib/source';
76
import { generatePageMetadata, getCanonicalUrl } from '@/lib/seo-utils';
87
import { getFinalPageTitle } from '@/lib/h1-extractor';
98
import { readFile } from 'fs/promises';
109
import { 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

1313
export 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

app/layout.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RootProvider } from 'fumadocs-ui/provider';
22
import type { ReactNode } from 'react';
33
import type { Metadata } from 'next';
4+
import { generateWebSiteSchema, generateOrganizationSchema, combineSchemas } from '@/lib/structured-data';
45
import './global.css'; // Import global styles
56

67
export const metadata: Metadata = {
@@ -25,8 +26,19 @@ export const metadata: Metadata = {
2526
};
2627

2728
export default function Layout({ children }: { children: ReactNode }) {
29+
// Generate site-wide structured data
30+
const websiteSchema = generateWebSiteSchema();
31+
const organizationSchema = generateOrganizationSchema();
32+
const structuredData = combineSchemas(websiteSchema, organizationSchema);
33+
2834
return (
2935
<html lang="en" suppressHydrationWarning>
36+
<head>
37+
<script
38+
type="application/ld+json"
39+
dangerouslySetInnerHTML={{ __html: structuredData }}
40+
/>
41+
</head>
3042
<body
3143
// Using Tailwind CSS classes for basic layout styling
3244
// Ensure these are compatible with Fumadocs/your design

0 commit comments

Comments
 (0)