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/fixed-482-sidebar-current-project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The docs sidebar now highlights rationguard, promptargs and dibs on their own pages instead of Hive; the current project is derived from the project hrefs (hivecommons/docs#482).
20 changes: 18 additions & 2 deletions src/__tests__/RelatedProjects.behavior.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ describe("project list and highlighting", () => {
expect(inactive.className).not.toContain("font-medium");
});

it("highlights projects without a hard-coded prefix, not Hive", () => {
pathname = "/docs/rationguard/overview/introduction";
useSharedConfigMock.mockReturnValue({
config: configWith([
{ title: "Hive", href: "/docs/hive/overview/introduction" },
{
title: "rationguard",
href: "/docs/rationguard/overview/introduction",
},
]),
});
render(<RelatedProjects />);
expect(screen.getByText("rationguard").className).toContain("font-medium");
expect(screen.getByText("Hive").className).not.toContain("font-medium");
});

it("falls back to Hive when no section prefix matches", () => {
pathname = "/docs/something-else";
render(<RelatedProjects />);
Expand Down Expand Up @@ -203,8 +219,8 @@ describe("renderLegacyMenuTree", () => {

function renderTree() {
// The tree renders only under the *current* secondary project, and
// getCurrentProject() recognizes a fixed set of pathname prefixes, so the
// secondary project must be one of those (pluk here).
// getCurrentProject() matches the pathname against the project hrefs, so
// the secondary project's href must be a prefix of the pathname.
pathname = "/docs/pluk";
useSharedConfigMock.mockReturnValue({
config: configWith([
Expand Down
11 changes: 5 additions & 6 deletions src/components/docs/RelatedProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ export function RelatedProjects({ variant = 'full', onCollapse, bannerActive = f
// Determine current project or section from pathname
// THIS HIGHLIGHTS THE ACTIVE PROJECT/SECTION IN THE PROJECT LIST IN THE SIDEBAR
const getCurrentProject = () => {
if (pathname.startsWith('/docs/hotshot')) return 'hotshot';
if (pathname.startsWith('/docs/a2a')) return 'A2A';
if (pathname.startsWith('/docs/kubeflex')) return 'KubeFlex';
if (pathname.startsWith('/docs/multi-plugin')) return 'Multi Plugin';
if (pathname.startsWith('/docs/pluk')) return 'pluk';
if (pathname.startsWith('/docs/spektacular')) return 'Spektacular';
const matched = allProjects.find((project) => {
const base = `/docs/${project.href.split('/')[2]}`;
return pathname === base || pathname.startsWith(`${base}/`);
});
if (matched) return matched.title;
if (pathname.startsWith('/docs/contributing')) return 'Contributing';
if (pathname.startsWith('/docs/community')) return 'Community';
if (pathname.startsWith('/docs/news')) return 'News';
Expand Down
Loading