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
1 change: 1 addition & 0 deletions changelog.d/changed-remove-legacy-sidebar-group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove the unreachable Legacy Components group from DocsSidebar (empty project list, uncalled renderer, dangling /docs/legacy-components link).
84 changes: 1 addition & 83 deletions src/components/docs/DocsSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ const PRIMARY_PROJECTS = [
{ id: 'spektacular', label: 'Spektacular', href: '/docs/spektacular/overview/introduction' },
] as const;

// No legacy projects on the Hive Commons docs site.
const LEGACY_PROJECTS: ReadonlyArray<{ id: string; label: string; href: string }> = [];

const ALL_PROJECTS = [...PRIMARY_PROJECTS, ...LEGACY_PROJECTS] as const;

// Key prefix for project-level collapse state (avoids collision with nav item keys)
const PROJECT_KEY_PREFIX = '__project_';
const LEGACY_GROUP_KEY = '__legacy';
const GENERAL_SECTION_PATH_REGEX = new RegExp(
`^/docs/(${GENERAL_SECTION_SLUGS.join('|')})(/|$)`,
);
Expand Down Expand Up @@ -77,8 +71,6 @@ function getFirstChildRoute(item: MenuItem): string | undefined {
return undefined;
}

const LEGACY_OVERVIEW_HREF = '/docs/legacy-components';

export function DocsSidebar({ pageMap, className, projectId }: DocsSidebarProps) {
const pathname = usePathname();
const sidebarRef = useRef<HTMLElement>(null);
Expand Down Expand Up @@ -152,19 +144,13 @@ export function DocsSidebar({ pageMap, className, projectId }: DocsSidebarProps)
const activeProjectId = projectId || 'hive';

// Keep non-active project sections collapsed by default
for (const proj of ALL_PROJECTS) {
for (const proj of PRIMARY_PROJECTS) {
const isProjectLink = currentPath === '/docs/introduction' || proj.id !== activeProjectId;
if (isProjectLink) {
initialCollapsed.add(`${PROJECT_KEY_PREFIX}${proj.id}`);
}
}

// Collapse legacy group if active project is not a legacy project
const legacyIds = LEGACY_PROJECTS.map(p => p.id) as readonly string[];
if (!legacyIds.includes(activeProjectId)) {
initialCollapsed.add(LEGACY_GROUP_KEY);
}

// For the active project, find the path to the active page and collapse non-active folders
const activeItems = getProjectItems(pageMap);
const activeParentKey = `${PROJECT_KEY_PREFIX}${activeProjectId}`;
Expand Down Expand Up @@ -226,18 +212,6 @@ export function DocsSidebar({ pageMap, className, projectId }: DocsSidebarProps)
setCollapsed(initialCollapsed);
}, [pageMap, projectId, navInitialized, setCollapsed]);

// Keep legacy group collapsed while browsing general sections
useEffect(() => {
if (!GENERAL_SECTION_PATH_REGEX.test(pathname)) return;

setCollapsed(prev => {
if (prev.has(LEGACY_GROUP_KEY)) return prev;
const next = new Set(prev);
next.add(LEGACY_GROUP_KEY);
return next;
});
}, [pathname, setCollapsed]);

const toggleCollapse = (itemKey: string) => {
toggleNavCollapsed(itemKey);
};
Expand Down Expand Up @@ -463,62 +437,6 @@ export function DocsSidebar({ pageMap, className, projectId }: DocsSidebarProps)
return renderProjectLink(proj.id, proj.label, proj.href, depth);
};

// Render the Legacy group with sub-projects
const renderLegacyGroup = () => {
const isExpanded = !collapsed.has(LEGACY_GROUP_KEY);
// Don't highlight Legacy Components when viewing docs guide or general sections
const isGeneralSectionPath = GENERAL_SECTION_PATH_REGEX.test(pathname);
const isActiveLegacy = !isDocsGuide && !isGeneralSectionPath && LEGACY_PROJECTS.some(p => p.id === projectId);

return (
<div className="relative pt-1">
<div
className={`
flex items-center gap-0 px-3 py-2 text-[13px] rounded-md transition-colors w-full font-semibold
${isActiveLegacy
? 'text-honey bg-bg-3'
: 'text-ink-3 hover:bg-bg-2 hover:bg-bg-2'
}
`}
>
<Link
href={LEGACY_OVERVIEW_HREF}
prefetch
onClick={() => { if (!isExpanded) toggleCollapse(LEGACY_GROUP_KEY); }}
className="flex-1 truncate"
>
Legacy Components
</Link>
<button
type="button"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
toggleCollapse(LEGACY_GROUP_KEY);
}}
className="ks-sidebar-chevron ml-auto shrink-0 p-0.5 rounded hover:bg-bg-3 transition-colors"
aria-label={isExpanded ? 'Collapse section' : 'Expand section'}
>
{isExpanded ? (
<ChevronDown className="w-3 h-3" />
) : (
<ChevronRight className="w-3 h-3" />
)}
</button>
</div>

<div
className={`
relative overflow-hidden transition-all duration-300 ease-in-out
${isExpanded ? 'max-h-[2000px] opacity-100' : 'max-h-0 opacity-0'}
`}
>
{LEGACY_PROJECTS.map(proj => renderProject(proj, 1))}
</div>
</div>
);
};

// Render full sidebar (expanded state)
const renderFullSidebar = () => {
// General sections (Contributing, Community, News) from current project's pageMap
Expand Down
Loading