Skip to content
Closed
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
47 changes: 37 additions & 10 deletions cloud/app/components/docs-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,30 @@ function createSidebarConfig(): SidebarConfig {
allSections.unshift(defaultSection);
}

// Helper to check if dev content should be filtered out in non-development
function shouldFilterDevContent(itemPath: string): boolean {
if (process.env.NODE_ENV === "development") {
return false;
}
return itemPath === "v1/placeholder";
}

// Convert doc specs to sidebar items
function convertDocToSidebarItem(
doc: DocSpec,
parentPath: string,
): SidebarItem {
): SidebarItem | undefined {
// Construct the logical path for this item (used to look up routePath)
const itemPath = parentPath ? `${parentPath}/${doc.slug}` : doc.slug;

// Look up the routePath from DocInfo if available
const routePath = slugToRoutePathMap.get(itemPath);

// todo(sebastian): reconcile placeholder with dev content
if (shouldFilterDevContent(itemPath)) {
return undefined;
}

// Determine hasContent: explicit value from doc, or default based on children
const hasContent = doc.hasContent ?? !doc.children;

Expand All @@ -80,7 +93,7 @@ function createSidebarConfig(): SidebarConfig {

doc.children.forEach((childDoc) => {
const childItem = convertDocToSidebarItem(childDoc, itemPath);
if (item.items) {
if (childItem && item.items) {
item.items[childDoc.slug] = childItem;
}
});
Expand Down Expand Up @@ -117,11 +130,21 @@ function createSidebarConfig(): SidebarConfig {
const groups: Record<string, SidebarGroup> = {};

section.children.forEach((child) => {
// Check if this item should be filtered out
const childPath = pathPrefix ? `${pathPrefix}/${child.slug}` : child.slug;
// todo(sebastian): reconcile placeholder with dev content
if (shouldFilterDevContent(childPath)) {
return; // Skip this item in non-dev environments
}

const hasContent = child.hasContent ?? !child.children;

if (hasContent) {
// This item has content, add it to items (even if it also has children)
items[child.slug] = convertDocToSidebarItem(child, pathPrefix);
const sidebarItem = convertDocToSidebarItem(child, pathPrefix);
if (sidebarItem) {
items[child.slug] = sidebarItem;
}
} else {
// This is a pure folder (no content), add it as a group
const groupItems: Record<string, SidebarItem> = {};
Expand All @@ -139,16 +162,20 @@ function createSidebarConfig(): SidebarConfig {
grandchild,
groupPathPrefix,
);
groupItems[grandchild.slug] = sidebarItem;
if (sidebarItem) {
groupItems[grandchild.slug] = sidebarItem;
}
});
}

// Add the group
groups[child.slug] = {
slug: child.slug,
label: child.label,
items: groupItems,
};
// Add the group only if it has items
if (Object.keys(groupItems).length > 0) {
groups[child.slug] = {
slug: child.slug,
label: child.label,
items: groupItems,
};
}
}
});

Expand Down
21 changes: 0 additions & 21 deletions cloud/app/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { Route as BlogSlugRouteImport } from './routes/blog.$slug'
import { Route as AuthMeRouteImport } from './routes/auth/me'
import { Route as AuthGoogleRouteImport } from './routes/auth/google'
import { Route as AuthGithubRouteImport } from './routes/auth/github'
import { Route as DocsV1PlaceholderRouteImport } from './routes/docs.v1.placeholder'
import { Route as DocsV1SplatRouteImport } from './routes/docs.v1.$'
import { Route as AuthGoogleProxyCallbackRouteImport } from './routes/auth/google.proxy-callback'
import { Route as AuthGoogleCallbackRouteImport } from './routes/auth/google.callback'
Expand Down Expand Up @@ -117,11 +116,6 @@ const AuthGithubRoute = AuthGithubRouteImport.update({
path: '/auth/github',
getParentRoute: () => rootRouteImport,
} as any)
const DocsV1PlaceholderRoute = DocsV1PlaceholderRouteImport.update({
id: '/v1/placeholder',
path: '/v1/placeholder',
getParentRoute: () => DocsRoute,
} as any)
const DocsV1SplatRoute = DocsV1SplatRouteImport.update({
id: '/v1/$',
path: '/v1/$',
Expand Down Expand Up @@ -199,7 +193,6 @@ export interface FileRoutesByFullPath {
'/auth/google/callback': typeof AuthGoogleCallbackRoute
'/auth/google/proxy-callback': typeof AuthGoogleProxyCallbackRoute
'/docs/v1/$': typeof DocsV1SplatRoute
'/docs/v1/placeholder': typeof DocsV1PlaceholderRoute
'/router/v0/$provider/$': typeof RouterV0ProviderSplatRoute
}
export interface FileRoutesByTo {
Expand Down Expand Up @@ -227,7 +220,6 @@ export interface FileRoutesByTo {
'/auth/google/callback': typeof AuthGoogleCallbackRoute
'/auth/google/proxy-callback': typeof AuthGoogleProxyCallbackRoute
'/docs/v1/$': typeof DocsV1SplatRoute
'/docs/v1/placeholder': typeof DocsV1PlaceholderRoute
'/router/v0/$provider/$': typeof RouterV0ProviderSplatRoute
}
export interface FileRoutesById {
Expand Down Expand Up @@ -257,7 +249,6 @@ export interface FileRoutesById {
'/auth/google/callback': typeof AuthGoogleCallbackRoute
'/auth/google/proxy-callback': typeof AuthGoogleProxyCallbackRoute
'/docs/v1/$': typeof DocsV1SplatRoute
'/docs/v1/placeholder': typeof DocsV1PlaceholderRoute
'/router/v0/$provider/$': typeof RouterV0ProviderSplatRoute
}
export interface FileRouteTypes {
Expand Down Expand Up @@ -288,7 +279,6 @@ export interface FileRouteTypes {
| '/auth/google/callback'
| '/auth/google/proxy-callback'
| '/docs/v1/$'
| '/docs/v1/placeholder'
| '/router/v0/$provider/$'
fileRoutesByTo: FileRoutesByTo
to:
Expand Down Expand Up @@ -316,7 +306,6 @@ export interface FileRouteTypes {
| '/auth/google/callback'
| '/auth/google/proxy-callback'
| '/docs/v1/$'
| '/docs/v1/placeholder'
| '/router/v0/$provider/$'
id:
| '__root__'
Expand Down Expand Up @@ -345,7 +334,6 @@ export interface FileRouteTypes {
| '/auth/google/callback'
| '/auth/google/proxy-callback'
| '/docs/v1/$'
| '/docs/v1/placeholder'
| '/router/v0/$provider/$'
fileRoutesById: FileRoutesById
}
Expand Down Expand Up @@ -485,13 +473,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthGithubRouteImport
parentRoute: typeof rootRouteImport
}
'/docs/v1/placeholder': {
id: '/docs/v1/placeholder'
path: '/v1/placeholder'
fullPath: '/docs/v1/placeholder'
preLoaderRoute: typeof DocsV1PlaceholderRouteImport
parentRoute: typeof DocsRoute
}
'/docs/v1/$': {
id: '/docs/v1/$'
path: '/v1/$'
Expand Down Expand Up @@ -579,12 +560,10 @@ const BlogRouteWithChildren = BlogRoute._addFileChildren(BlogRouteChildren)

interface DocsRouteChildren {
DocsV1SplatRoute: typeof DocsV1SplatRoute
DocsV1PlaceholderRoute: typeof DocsV1PlaceholderRoute
}

const DocsRouteChildren: DocsRouteChildren = {
DocsV1SplatRoute: DocsV1SplatRoute,
DocsV1PlaceholderRoute: DocsV1PlaceholderRoute,
}

const DocsRouteWithChildren = DocsRoute._addFileChildren(DocsRouteChildren)
Expand Down
59 changes: 0 additions & 59 deletions cloud/app/routes/docs.v1.placeholder.tsx

This file was deleted.