Skip to content

Commit 896f662

Browse files
optimized the server side slow issues from vercel speed insights
1 parent 2e781bc commit 896f662

16 files changed

Lines changed: 736 additions & 687 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** Main-column fallback while docs page data (content + permissions) resolves. */
2+
export function DocsContentSkeleton() {
3+
return (
4+
<div className="flex flex-1 flex-col gap-4 p-6">
5+
<div className="h-8 w-1/3 max-w-xs animate-pulse rounded-md bg-gray-100" />
6+
<div className="h-4 w-full max-w-2xl animate-pulse rounded-md bg-gray-50" />
7+
<div className="h-4 w-5/6 max-w-xl animate-pulse rounded-md bg-gray-50" />
8+
<div className="mt-6 min-h-[50vh] w-full animate-pulse rounded-lg bg-gray-50" />
9+
</div>
10+
);
11+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {
2+
processProjects,
3+
processYourDocs,
4+
processPublishedDocs,
5+
buildSidebarItems,
6+
type ProcessedYourDoc,
7+
} from '@/lib/docs';
8+
import { getDocsNavBundleForUser } from '@/lib/db';
9+
import { DocsLayoutClient } from '@/components/docs/DocsLayoutClient';
10+
import { FontLoader } from '@/components/FontLoader';
11+
12+
export async function DocsLayoutWithNav({
13+
userId,
14+
children,
15+
}: {
16+
userId: string;
17+
children: React.ReactNode;
18+
}) {
19+
const { data, publishedDocsData } = await getDocsNavBundleForUser(userId);
20+
const processedProjects = processProjects(data.projects);
21+
const processedYourDocs = processYourDocs(data.yourDocs);
22+
23+
let processedPublishedDocs: ProcessedYourDoc[] = [];
24+
try {
25+
const publishSlugsMap = new Map(Object.entries(publishedDocsData.publishSlugs));
26+
processedPublishedDocs = processPublishedDocs(
27+
publishedDocsData.documents,
28+
publishSlugsMap
29+
);
30+
} catch (error) {
31+
console.error('Error fetching published docs:', error);
32+
processedPublishedDocs = [];
33+
}
34+
35+
const sidebarItems = buildSidebarItems(
36+
processedProjects,
37+
processedYourDocs,
38+
processedPublishedDocs,
39+
data.ownership
40+
);
41+
42+
return (
43+
<>
44+
<FontLoader />
45+
<DocsLayoutClient
46+
sidebarItems={sidebarItems}
47+
processedProjects={processedProjects}
48+
processedYourDocs={processedYourDocs}
49+
>
50+
{children}
51+
</DocsLayoutClient>
52+
</>
53+
);
54+
}

0 commit comments

Comments
 (0)