-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_layout.sh
More file actions
50 lines (42 loc) · 1.3 KB
/
patch_layout.sh
File metadata and controls
50 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cat << 'INNER_EOF' > apps/docs/src/app/docs/layout.tsx
import { source } from '@/lib/source';
import { DocsLayout } from 'fumadocs-ui/layouts/notebook';
import { baseOptions } from '@/lib/layout.shared';
import type { ReactNode } from 'react';
import { Gem } from 'lucide-react';
const PRO_PLUGINS = ['trail', 'geminitts'];
function patchTree(node: any): any {
if (!node) return node;
if (node.type === 'page') {
const isPro = PRO_PLUGINS.some(p => node.url.includes('/plugins/' + p));
if (isPro) {
return {
...node,
name: (
<div className="flex items-center gap-1">
<span className="text-orange-500 font-medium">{node.name}</span>
<Gem className="w-3.5 h-3.5 text-orange-500" title="Pro" />
</div>
),
};
}
}
if (node.children) {
return { ...node, children: node.children.map(patchTree) };
}
return node;
}
export default function Layout({ children }: { children: ReactNode }) {
const { nav, ...base } = baseOptions();
const originalTree = source.getPageTree();
const patchedTree = {
...originalTree,
children: originalTree.children.map(patchTree),
};
return (
<DocsLayout tree={patchedTree as any} {...base} nav={{ ...nav, mode: 'top' }}>
{children}
</DocsLayout>
);
}
INNER_EOF