Skip to content

Commit 20b477e

Browse files
committed
Fix build
1 parent bfe5579 commit 20b477e

File tree

6 files changed

+78
-12
lines changed

6 files changed

+78
-12
lines changed

apps/www/public/tailwind.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/www/src/app/(app)/docs/[[...slug]]/page.tsx

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { notFound } from "next/navigation"
1313

1414
import { DocContent } from "@/app/(app)/docs/[[...slug]]/doc-content"
1515
import { ComponentInstallation } from "@/components/component-installation"
16-
import { ComponentPreviewInternal } from "@/components/component-preview-internal"
16+
import { ComponentPreview } from '@/components/component-preview'
1717
import { DocsTableOfContents } from "@/components/docs-toc"
1818
import { LLMCopyButton } from '@/components/llm-copy-button'
1919
import { mdxComponents } from "@/components/mdx-components"
@@ -45,6 +45,67 @@ export const dynamicParams = true
4545

4646
const registryNames = new Set(registry.items.map((item) => item.name))
4747

48+
// Helper function to filter page tree by locale
49+
function filterPageTreeByLocale(pageTree: any, isChinese: boolean): any {
50+
if (!pageTree) return pageTree
51+
52+
// Filter children array recursively
53+
const filterChildren = (children: any[]): any[] => {
54+
if (!children) return []
55+
56+
return children
57+
.map((node: any) => {
58+
// Handle separator nodes
59+
if (node.type === 'separator') {
60+
return node
61+
}
62+
63+
// Handle folder nodes
64+
if (node.type === 'folder') {
65+
const filteredChildren = filterChildren(node.children)
66+
// Only include folder if it has children after filtering
67+
if (filteredChildren.length === 0 && !node.index) {
68+
return null
69+
}
70+
71+
// Check if folder index should be filtered
72+
if (node.index?.url) {
73+
const isChineseNode = node.index.url.includes('.cn')
74+
if (isChinese !== isChineseNode) {
75+
// Filter out the index but keep the folder if it has other valid children
76+
return {
77+
...node,
78+
children: filteredChildren,
79+
index: undefined
80+
}
81+
}
82+
}
83+
84+
return {
85+
...node,
86+
children: filteredChildren
87+
}
88+
}
89+
90+
// Handle page nodes
91+
if (node.url) {
92+
const isChineseNode = node.url.includes('.cn')
93+
if (isChinese !== isChineseNode) {
94+
return null
95+
}
96+
}
97+
98+
return node
99+
})
100+
.filter(Boolean) // Remove null entries
101+
}
102+
103+
return {
104+
...pageTree,
105+
children: filterChildren(pageTree.children)
106+
}
107+
}
108+
48109
export function generateStaticParams() {
49110
return docsSource.generateParams()
50111
}
@@ -241,8 +302,9 @@ export default async function Page(props: DocPageProps) {
241302
usage={file.meta?.usage}
242303
/>
243304
) : (
244-
<ComponentPreviewInternal
305+
<ComponentPreview
245306
name={file.name}
307+
item={item}
246308
/>
247309
)}
248310
</DocContent>
@@ -251,7 +313,11 @@ export default async function Page(props: DocPageProps) {
251313

252314
const doc = page.data
253315
const MDX = doc.body
254-
const neighbours = findNeighbour(docsSource.pageTree, page.url)
316+
317+
// Filter neighbors to only include same language pages
318+
const isChinese = page.url.includes('.cn')
319+
const filteredPageTree = filterPageTreeByLocale(docsSource.pageTree, isChinese)
320+
const neighbours = findNeighbour(filteredPageTree, page.url)
255321

256322
// Add description from docsMap if not present
257323
if (!doc.description) {
@@ -282,7 +348,8 @@ export default async function Page(props: DocPageProps) {
282348
<h1 className="scroll-m-20 text-4xl font-semibold tracking-tight sm:text-3xl xl:text-4xl">
283349
{doc.title}
284350
</h1>
285-
<div className="flex items-center gap-2 pt-1.5">
351+
{/* TODO: FIX */}
352+
{/* <div className="flex items-center gap-2 pt-1.5">
286353
{neighbours.previous && (
287354
<Button
288355
asChild
@@ -309,7 +376,7 @@ export default async function Page(props: DocPageProps) {
309376
</Link>
310377
</Button>
311378
)}
312-
</div>
379+
</div> */}
313380
</div>
314381
{doc.description && (
315382
<p className="text-muted-foreground text-[1.05rem] text-balance sm:text-base">

apps/www/src/components/block-display.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import type { RegistryItem, registryItemFileSchema } from "shadcn/registry"
44
import type { z } from "zod"
55

66
import { BlockViewer } from "@/components/block-viewer"
7-
import { ComponentPreviewInternal } from "@/components/component-preview-internal"
87
import { highlightCode } from "@/lib/highlight-code"
98
import { createFileTreeForRegistryItemFiles, getRegistryItem } from "@/lib/rehype-utils"
10-
import { cn } from "@/lib/utils"
119

1210
export interface BlockDisplayProps {
1311
item: RegistryItem
@@ -32,14 +30,14 @@ export async function BlockDisplay({ block = true, codeOnly, item: itemProp, nam
3230
return (
3331
<BlockViewer blocks={block} codeOnly={codeOnly} highlightedFiles={highlightedFiles} item={item} tree={tree}
3432
>
35-
<ComponentPreviewInternal
33+
{/* <ComponentPreviewInternal
3634
name={item.name}
3735
className={cn(
3836
"my-0 **:[.preview]:h-auto **:[.preview]:p-4 **:[.preview>.p-6]:p-0",
3937
item.meta?.containerClassName
4038
)}
4139
hideCode
42-
/>
40+
/> */}
4341
</BlockViewer>
4442
)
4543
}

apps/www/src/components/block-viewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ function BlockViewer({
555555
<BlockViewerCode />
556556
</React.Fragment>
557557
}
558-
<BlockViewerMobile>{children}</BlockViewerMobile>
558+
{/* <BlockViewerMobile>{children}</BlockViewerMobile> */}
559559
</BlockViewerProvider>
560560
)
561561
}

apps/www/src/components/component-installation.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function ComponentInstallation({
4444
usage,
4545
...props
4646
}: ComponentInstallationProps) {
47+
// Special handling for API route items
4748
const dependencies =
4849
props.dependencies ?? getAllDependencies(name) ?? JSON.parse(__registryDependencies__);
4950

apps/www/src/lib/highlight-code.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { codeToHtml } from 'shiki';
66
export async function highlightFiles(
77
files?: z.infer<typeof registryItemFileSchema>[]
88
) {
9-
if (!files) {
9+
if (!files || files.length === 0) {
1010
return null;
1111
}
1212

0 commit comments

Comments
 (0)