Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/fumadocs/src/docs-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ describe("createDocsLayout pageActions", () => {
expect(props?.pageActionsPosition).toBe("below-title");
});

it("does not add an extra display: contents wrapper above the docs layout root", () => {
const Layout = createDocsLayout({
entry: "docs",
});

const tree = Layout({
children: React.createElement("div", null, "child"),
});

expect(React.isValidElement(tree)).toBe(true);
expect(tree.type).not.toBe("div");
expect((tree.props as { id?: string; style?: { display?: string } }).id).toBeUndefined();
expect(
(tree.props as { id?: string; style?: { display?: string } }).style?.display,
).toBeUndefined();
});

it("supports boolean shorthand, custom providers, and above-title placement", () => {
const Layout = createDocsLayout({
entry: "docs",
Expand Down
144 changes: 71 additions & 73 deletions packages/fumadocs/src/docs-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -955,81 +955,79 @@ export function createDocsLayout(config: DocsConfig, options?: { locale?: string
}

return (
<div id="nd-docs-layout" style={{ display: "contents" }}>
<DocsLayout
tree={localizedTree}
nav={{ title: navTitle, url: navUrl }}
themeSwitch={i18n ? { ...themeSwitch, enabled: false } : themeSwitch}
sidebar={finalSidebarProps}
{...(aiMode === "sidebar-icon" && aiEnabled
? {
searchToggle: { components: { lg: <SidebarSearchWithAI /> } },
}
: {})}
>
<ColorStyle colors={colors} />
<TypographyStyle typography={typography} />
<LayoutStyle layout={layoutDimensions} />
{forcedTheme && <ForcedThemeScript theme={forcedTheme} />}
{!staticExport && (
<Suspense fallback={null}>
<DocsCommandSearch api={docsApiUrl} locale={activeLocale} />
</Suspense>
)}
{aiEnabled && (
<Suspense fallback={null}>
<DocsAIFeatures
mode={aiMode}
api={docsApiUrl}
locale={activeLocale}
position={aiPosition}
floatingStyle={aiFloatingStyle}
triggerComponentHtml={aiTriggerComponentHtml}
suggestedQuestions={aiSuggestedQuestions}
aiLabel={aiLabel}
loaderVariant={aiLoaderVariant}
loadingComponentHtml={aiLoadingComponentHtml}
models={aiModels}
defaultModelId={aiDefaultModelId}
/>
</Suspense>
)}
<Suspense fallback={children}>
<DocsPageClient
tocEnabled={tocEnabled}
tocStyle={tocStyle}
breadcrumbEnabled={breadcrumbEnabled}
changelogBasePath={changelogBasePath}
entry={localeContext.entryPath}
<DocsLayout
tree={localizedTree}
nav={{ title: navTitle, url: navUrl }}
themeSwitch={i18n ? { ...themeSwitch, enabled: false } : themeSwitch}
sidebar={finalSidebarProps}
{...(aiMode === "sidebar-icon" && aiEnabled
? {
searchToggle: { components: { lg: <SidebarSearchWithAI /> } },
}
: {})}
>
<ColorStyle colors={colors} />
<TypographyStyle typography={typography} />
<LayoutStyle layout={layoutDimensions} />
{forcedTheme && <ForcedThemeScript theme={forcedTheme} />}
{!staticExport && (
<Suspense fallback={null}>
<DocsCommandSearch api={docsApiUrl} locale={activeLocale} />
</Suspense>
)}
{aiEnabled && (
<Suspense fallback={null}>
<DocsAIFeatures
mode={aiMode}
api={docsApiUrl}
locale={activeLocale}
copyMarkdown={copyMarkdownEnabled}
openDocs={openDocsEnabled}
openDocsProviders={openDocsProviders as any}
pageActionsPosition={pageActionsPosition}
pageActionsAlignment={pageActionsAlignment}
githubUrl={githubUrl}
contentDir={contentDir}
githubBranch={githubBranch}
githubDirectory={githubDirectory}
lastModifiedMap={lastModifiedMap}
lastUpdatedEnabled={lastUpdatedEnabled}
lastUpdatedPosition={lastUpdatedPosition}
readingTimeEnabled={readingTimeEnabled}
readingTimeMap={readingTimeMap}
llmsTxtEnabled={llmsTxtEnabled}
descriptionMap={descriptionMap}
feedbackEnabled={feedbackConfig.enabled}
feedbackQuestion={feedbackConfig.question}
feedbackPlaceholder={feedbackConfig.placeholder}
feedbackPositiveLabel={feedbackConfig.positiveLabel}
feedbackNegativeLabel={feedbackConfig.negativeLabel}
feedbackSubmitLabel={feedbackConfig.submitLabel}
>
{children}
</DocsPageClient>
position={aiPosition}
floatingStyle={aiFloatingStyle}
triggerComponentHtml={aiTriggerComponentHtml}
suggestedQuestions={aiSuggestedQuestions}
aiLabel={aiLabel}
loaderVariant={aiLoaderVariant}
loadingComponentHtml={aiLoadingComponentHtml}
models={aiModels}
defaultModelId={aiDefaultModelId}
/>
</Suspense>
</DocsLayout>
</div>
)}
<Suspense fallback={children}>
<DocsPageClient
tocEnabled={tocEnabled}
tocStyle={tocStyle}
breadcrumbEnabled={breadcrumbEnabled}
changelogBasePath={changelogBasePath}
entry={localeContext.entryPath}
locale={activeLocale}
copyMarkdown={copyMarkdownEnabled}
openDocs={openDocsEnabled}
openDocsProviders={openDocsProviders as any}
pageActionsPosition={pageActionsPosition}
pageActionsAlignment={pageActionsAlignment}
githubUrl={githubUrl}
contentDir={contentDir}
githubBranch={githubBranch}
githubDirectory={githubDirectory}
lastModifiedMap={lastModifiedMap}
lastUpdatedEnabled={lastUpdatedEnabled}
lastUpdatedPosition={lastUpdatedPosition}
readingTimeEnabled={readingTimeEnabled}
readingTimeMap={readingTimeMap}
llmsTxtEnabled={llmsTxtEnabled}
descriptionMap={descriptionMap}
feedbackEnabled={feedbackConfig.enabled}
feedbackQuestion={feedbackConfig.question}
feedbackPlaceholder={feedbackConfig.placeholder}
feedbackPositiveLabel={feedbackConfig.positiveLabel}
feedbackNegativeLabel={feedbackConfig.negativeLabel}
feedbackSubmitLabel={feedbackConfig.submitLabel}
>
{children}
</DocsPageClient>
</Suspense>
</DocsLayout>
);
};
}
Expand Down
25 changes: 25 additions & 0 deletions packages/fumadocs/src/tanstack-layout.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { describe, expect, it } from "vitest";
import { TanstackDocsLayout } from "./tanstack-layout.js";

describe("TanstackDocsLayout", () => {
it("does not add an extra display: contents wrapper above the docs layout root", () => {
const tree = TanstackDocsLayout({
config: {
entry: "docs",
},
tree: {
name: "Docs",
children: [],
},
children: React.createElement("div", null, "child"),
});

expect(React.isValidElement(tree)).toBe(true);
expect(tree.type).not.toBe("div");
expect((tree.props as { id?: string; style?: { display?: string } }).id).toBeUndefined();
expect(
(tree.props as { id?: string; style?: { display?: string } }).style?.display,
).toBeUndefined();
});
});
132 changes: 65 additions & 67 deletions packages/fumadocs/src/tanstack-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -440,74 +440,72 @@ export function TanstackDocsLayout({
}

return (
<div id="nd-docs-layout" style={{ display: "contents" }}>
<DocsLayout
tree={resolvedTree}
nav={{ title: navTitle, url: navUrl }}
themeSwitch={locale && i18n?.locales ? { ...themeSwitch, enabled: false } : themeSwitch}
sidebar={finalSidebarProps}
{...(aiMode === "sidebar-icon" && aiEnabled
? {
searchToggle: { components: { lg: <SidebarSearchWithAI /> } },
}
: {})}
>
<ColorStyle colors={colors} />
<TypographyStyle typography={typography} />
<LayoutStyle layout={layoutDimensions} />
{forcedTheme && <ForcedThemeScript theme={forcedTheme} />}
{!staticExport && (
<Suspense fallback={null}>
<DocsCommandSearch api={docsApiUrl} locale={locale} />
</Suspense>
)}
{aiEnabled && (
<Suspense fallback={null}>
<DocsAIFeatures
mode={aiMode}
api={docsApiUrl}
locale={locale}
position={aiPosition}
floatingStyle={aiFloatingStyle}
suggestedQuestions={aiSuggestedQuestions}
aiLabel={aiLabel}
loaderVariant={aiLoaderVariant}
models={aiModels}
defaultModelId={aiDefaultModelId}
/>
</Suspense>
)}
<Suspense fallback={children}>
<DocsPageClient
tocEnabled={tocEnabled}
tocStyle={tocStyle}
breadcrumbEnabled={breadcrumbEnabled}
entry={config.entry ?? "docs"}
<DocsLayout
tree={resolvedTree}
nav={{ title: navTitle, url: navUrl }}
themeSwitch={locale && i18n?.locales ? { ...themeSwitch, enabled: false } : themeSwitch}
sidebar={finalSidebarProps}
{...(aiMode === "sidebar-icon" && aiEnabled
? {
searchToggle: { components: { lg: <SidebarSearchWithAI /> } },
}
: {})}
>
<ColorStyle colors={colors} />
<TypographyStyle typography={typography} />
<LayoutStyle layout={layoutDimensions} />
{forcedTheme && <ForcedThemeScript theme={forcedTheme} />}
{!staticExport && (
<Suspense fallback={null}>
<DocsCommandSearch api={docsApiUrl} locale={locale} />
</Suspense>
)}
{aiEnabled && (
<Suspense fallback={null}>
<DocsAIFeatures
mode={aiMode}
api={docsApiUrl}
locale={locale}
copyMarkdown={copyMarkdownEnabled}
openDocs={openDocsEnabled}
openDocsProviders={openDocsProviders}
pageActionsPosition={pageActionsPosition}
pageActionsAlignment={pageActionsAlignment}
editOnGithubUrl={editOnGithubUrl}
lastUpdatedEnabled={lastUpdatedEnabled}
lastUpdatedPosition={lastUpdatedPosition}
lastModified={lastModified}
readingTimeEnabled={readingTimeEnabled}
readingTime={typeof readingTime === "number" ? readingTime : undefined}
llmsTxtEnabled={llmsTxtEnabled}
description={description}
feedbackEnabled={feedbackConfig.enabled}
feedbackQuestion={feedbackConfig.question}
feedbackPlaceholder={feedbackConfig.placeholder}
feedbackPositiveLabel={feedbackConfig.positiveLabel}
feedbackNegativeLabel={feedbackConfig.negativeLabel}
feedbackSubmitLabel={feedbackConfig.submitLabel}
>
{children}
</DocsPageClient>
position={aiPosition}
floatingStyle={aiFloatingStyle}
suggestedQuestions={aiSuggestedQuestions}
aiLabel={aiLabel}
loaderVariant={aiLoaderVariant}
models={aiModels}
defaultModelId={aiDefaultModelId}
/>
</Suspense>
</DocsLayout>
</div>
)}
<Suspense fallback={children}>
<DocsPageClient
tocEnabled={tocEnabled}
tocStyle={tocStyle}
breadcrumbEnabled={breadcrumbEnabled}
entry={config.entry ?? "docs"}
locale={locale}
copyMarkdown={copyMarkdownEnabled}
openDocs={openDocsEnabled}
openDocsProviders={openDocsProviders}
pageActionsPosition={pageActionsPosition}
pageActionsAlignment={pageActionsAlignment}
editOnGithubUrl={editOnGithubUrl}
lastUpdatedEnabled={lastUpdatedEnabled}
lastUpdatedPosition={lastUpdatedPosition}
lastModified={lastModified}
readingTimeEnabled={readingTimeEnabled}
readingTime={typeof readingTime === "number" ? readingTime : undefined}
llmsTxtEnabled={llmsTxtEnabled}
description={description}
feedbackEnabled={feedbackConfig.enabled}
feedbackQuestion={feedbackConfig.question}
feedbackPlaceholder={feedbackConfig.placeholder}
feedbackPositiveLabel={feedbackConfig.positiveLabel}
feedbackNegativeLabel={feedbackConfig.negativeLabel}
feedbackSubmitLabel={feedbackConfig.submitLabel}
>
{children}
</DocsPageClient>
</Suspense>
</DocsLayout>
);
}
Loading