Skip to content

Commit 3233e6f

Browse files
authored
docs: clickable sidebar headers, fix casing, and keep groups open (opensearch-project#105)
- Add custom Sidebar component with clickable group headers for Agent Health, Evaluations, Traces, and Configuration - Hide index pages from sidebar via sidebar.hidden frontmatter - Fix lowercase group labels (evaluations -> Evaluations, etc.) - Keep parent groups open when navigating to child pages Signed-off-by: Megha Goyal <goyamegh@amazon.com>
1 parent 5edcd0c commit 3233e6f

7 files changed

Lines changed: 96 additions & 5 deletions

File tree

docs/starlight-docs/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default defineConfig({
3333
components: {
3434
Header: './src/components/CustomHeader.astro',
3535
PageSidebar: './src/components/PageSidebar.astro',
36+
Sidebar: './src/components/Sidebar.astro',
3637
},
3738
sidebar: [
3839
{
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
import Default from '@astrojs/starlight/components/Sidebar.astro';
3+
4+
// Map of sidebar group labels to their display name and index page URL.
5+
// Keys match the rendered label text; displayName fixes casing if needed.
6+
const groupLinks: Record<string, { displayName: string; href: string }> = {
7+
'Agent Health': { displayName: 'Agent Health', href: '/docs/agent-health/' },
8+
'evaluations': { displayName: 'Evaluations', href: '/docs/agent-health/evaluations/' },
9+
'traces': { displayName: 'Traces', href: '/docs/agent-health/traces/' },
10+
'configuration': { displayName: 'Configuration', href: '/docs/agent-health/configuration/' },
11+
};
12+
---
13+
14+
<div data-group-links={JSON.stringify(groupLinks)}>
15+
<Default><slot /></Default>
16+
</div>
17+
18+
<script>
19+
function makeGroupHeadersClickable() {
20+
const container = document.querySelector('[data-group-links]');
21+
if (!container) return;
22+
const groupLinks: Record<string, { displayName: string; href: string }> = JSON.parse(
23+
container.getAttribute('data-group-links') || '{}'
24+
);
25+
26+
const groups = document.querySelectorAll('nav.sidebar details');
27+
for (const group of groups) {
28+
const summary = group.querySelector('summary');
29+
const label = summary?.querySelector('.group-label .large') as HTMLElement | null;
30+
if (!summary || !label) continue;
31+
32+
const labelText = label.textContent?.trim() ?? '';
33+
if (!(labelText in groupLinks)) continue;
34+
35+
const { displayName, href } = groupLinks[labelText];
36+
37+
const anchor = document.createElement('a');
38+
anchor.href = href;
39+
anchor.textContent = displayName;
40+
anchor.className = 'group-header-link';
41+
42+
const isCurrentPage =
43+
window.location.pathname === href ||
44+
window.location.pathname === href.replace(/\/$/, '');
45+
46+
const isChildPage = window.location.pathname.startsWith(href);
47+
48+
if (isCurrentPage) {
49+
anchor.setAttribute('aria-current', 'page');
50+
}
51+
52+
// Open this group and all ancestors if we're on this page
53+
// or any child page within this section
54+
if (isCurrentPage || isChildPage) {
55+
let el: HTMLElement | null = group as HTMLElement;
56+
while (el) {
57+
if (el.tagName === 'DETAILS') (el as HTMLDetailsElement).open = true;
58+
el = el.parentElement;
59+
}
60+
}
61+
62+
label.textContent = '';
63+
label.appendChild(anchor);
64+
65+
// When clicking the link: prevent the summary toggle, keep it open, navigate
66+
summary.addEventListener('click', (e) => {
67+
if ((e.target as HTMLElement).closest('.group-header-link')) {
68+
e.preventDefault();
69+
(group as HTMLDetailsElement).open = true;
70+
window.location.href = anchor.href;
71+
}
72+
});
73+
}
74+
}
75+
76+
makeGroupHeadersClickable();
77+
document.addEventListener('astro:after-swap', makeGroupHeadersClickable);
78+
</script>

docs/starlight-docs/src/content/docs/agent-health/configuration/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Configuration"
33
description: "Configure Agent Health to connect your AI agent, set up storage, and customize evaluation behavior"
44
sidebar:
5-
order: 7
5+
hidden: true
66
---
77

88
Agent Health works out of the box with demo data and file-based storage. Configure it when you're ready to connect your own agent or use production services.

docs/starlight-docs/src/content/docs/agent-health/evaluations/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Evaluations"
33
description: "How Agent Health evaluates AI agents using Golden Path trajectory comparison and LLM judges"
44
sidebar:
5-
order: 3
5+
hidden: true
66
---
77

88
Agent Health evaluates AI agents by comparing their execution trajectories against expected outcomes using an LLM judge. This page explains the evaluation pipeline and core concepts.

docs/starlight-docs/src/content/docs/agent-health/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
title: "Agent Health"
33
description: "Evaluation and observability framework for AI agents with Golden Path trajectory comparison"
44
sidebar:
5-
label: "Overview"
6-
order: 1
5+
hidden: true
76
---
87

98
Agent Health is an evaluation and observability framework for AI agents. It helps you measure agent performance through "Golden Path" trajectory comparison — where an LLM judge evaluates agent actions against expected outcomes. Check out the [GitHub repository](https://github.com/opensearch-project/agent-health) for source code and contributions.

docs/starlight-docs/src/content/docs/agent-health/traces/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Trace Visualization"
33
description: "Real-time trace monitoring and comparison for AI agent executions in Agent Health"
44
sidebar:
5-
order: 6
5+
hidden: true
66
---
77

88
Agent Health provides built-in trace visualization for monitoring and debugging AI agent executions. If your agent emits OpenTelemetry traces, Agent Health can display them alongside evaluation results.

docs/starlight-docs/src/styles/custom.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,16 @@
1414
.sl-markdown-content .icon-card-list li {
1515
margin: 0 !important;
1616
}
17+
18+
/* Clickable sidebar group header links */
19+
.group-header-link {
20+
color: inherit;
21+
text-decoration: none;
22+
}
23+
.group-header-link:hover {
24+
text-decoration: underline;
25+
color: var(--sl-color-text-accent);
26+
}
27+
.group-header-link[aria-current='page'] {
28+
color: var(--sl-color-text-accent);
29+
}

0 commit comments

Comments
 (0)