Is it possible to have tab based doc layout ? #1280
Unanswered
akrpersonified
asked this question in
Q&A
Replies: 2 comments 9 replies
-
You can render different stuffs on |
Beta Was this translation helpful? Give feedback.
5 replies
-
Hello @akrpersonified and @fuma-nama you can simply make it by import { DocsLayout, type DocsLayoutProps } from 'fumadocs-ui/layouts/docs';
import type { ReactNode } from 'react';
import { AlbumIcon, Heart, LayoutTemplate, MessageCircle } from 'lucide-react';
import { baseOptions } from '@/app/layout.config';
import 'fumadocs-twoslash/twoslash.css';
import { source } from '@/lib/source';
import { AlbumIcon, Heart, LayoutTemplate, MessageCircle } from 'lucide-react';
// Define the sidebar tabs and dynamic transformation logic
const sidebarTabs = [
{
text: 'Home of Docs',
url: '/docs',
title: 'Home of Docs',
description: 'Home of Docs',
icon: <AlbumIcon size={24} />, // sample icon
},
{
text: 'projectname',
url: '/docs/projectname',
title: 'projectname',
description: 'name of project',
icon: <AlbumIcon size={24} />, //sample icon only
},
];
const docsOptions: DocsLayoutProps = {
...baseOptions,
tree: source.pageTree,
links: sidebarTabs,
sidebar: {
tabs: {
transform(option, node) {
const meta = source.getNodeMeta(node);
if (!meta) return option;
return {
...option,
icon: (
<div
className="rounded-md border bg-gradient-to-t from-fd-background/80 p-1 shadow-md [&_svg]:size-5"
style={{
color: `hsl(var(--${meta.file.dirname}-color))`,
backgroundColor: `hsl(var(--${meta.file.dirname}-color)/.3)`,
}}
>
{node.icon}
</div>
),
};
},
}
},
};
export default function Layout({ children }: { children: ReactNode }) {
return <DocsLayout {...docsOptions}>{children}</DocsLayout>;
} then the
{
"title": "Getting Started",
"description": "A Brief Introduction on how to get started!",
"icon": "Building2",
"root": true,
"pages": [
"---Introduction---",
"index", #home of docs
"other"# here you should include all the home mdx by comma separation
"---Projects---", # group the projects
"...", #load all the mdx files
]
}
{
"title": "Getting Started",
"description": "A Brief Introduction on how to get started!",
"icon": "Building2",
"root": true,
"pages": [
"---Introduction---",
"index", #home of your project
"---Project Versions---", # group the projects
"...", # this will load all the project versions under project versions and when you click this will display that version
# make sure to add all versions under separate folders under the project name folder and include those in meta.json
]
} I hope this helps :) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want something like this in mantine docs : [https://mantine.dev/core/menu/](mantine example) . The whole page is divided into tabs and the "the table of contents" also changes when you change the tab. It seems that they create a new route when tab changes and they re render the whole page. Is it possible to have sth like this. Currently , I can create tabs but the right hand side bar "on this page" doesn't change when we change the tabs. Is there any way to implement this in fuma because it will help a lot as I can contain more information in one page ?
Beta Was this translation helpful? Give feedback.
All reactions