Skip to content

Commit 1e3c885

Browse files
Kyle McLarenclaude
andcommitted
Add sidebar group navigation and fix PUT icon
- Click sidebar group heading to expand and navigate to first item - Hold shift/ctrl/cmd to toggle without navigating - Change PUT icon to match POST (arrow up-right) but orange 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 468a81b commit 1e3c885

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

src/components/Head.astro

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,51 @@ const breadcrumbSchema = {
184184
resizeTimer = setTimeout(initCodeBlocks, 100);
185185
});
186186
</script>
187+
188+
<!-- Sidebar group navigation: click heading to expand and navigate to first item -->
189+
<script>
190+
function initSidebarNavigation() {
191+
// Find all nested sidebar groups within API Reference
192+
const sidebarGroups = document.querySelectorAll('nav[aria-label="Main"] details details');
193+
194+
sidebarGroups.forEach((details) => {
195+
const summary = details.querySelector(':scope > summary');
196+
if (!summary) return;
197+
198+
// Skip if already initialized
199+
if (summary.dataset.navInit) return;
200+
summary.dataset.navInit = 'true';
201+
202+
// Find the first link within this group
203+
const firstLink = details.querySelector(':scope > ul a[href]');
204+
if (!firstLink) return;
205+
206+
// Add click handler to summary
207+
summary.addEventListener('click', (e) => {
208+
// Only navigate if the group is currently collapsed (will be opened)
209+
// or if shift/ctrl/cmd is held (allow normal toggle behavior)
210+
if (e.shiftKey || e.ctrlKey || e.metaKey) return;
211+
212+
// If currently closed, navigate to first item
213+
if (!details.open) {
214+
e.preventDefault();
215+
details.open = true;
216+
// Navigate to the first item's URL
217+
window.location.href = firstLink.getAttribute('href');
218+
}
219+
// If already open, just toggle closed (default behavior)
220+
});
221+
222+
// Make summary look clickable
223+
summary.style.cursor = 'pointer';
224+
});
225+
}
226+
227+
// Run on initial load and page transitions
228+
if (document.readyState === 'loading') {
229+
document.addEventListener('DOMContentLoaded', initSidebarNavigation);
230+
} else {
231+
initSidebarNavigation();
232+
}
233+
document.addEventListener('astro:page-load', initSidebarNavigation);
234+
</script>

src/styles/custom.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,13 +1215,13 @@ nav[aria-label="Main"] a[data-method="post"][aria-current="page"]::after {
12151215
background-color: white;
12161216
}
12171217

1218-
/* PUT - Orange arrows up/down */
1218+
/* PUT - Orange arrow up-right (same as POST) */
12191219
nav[aria-label="Main"] a[data-method="put"]::before {
12201220
background-color: var(--http-put-faint);
12211221
}
12221222
nav[aria-label="Main"] a[data-method="put"]::after {
12231223
background-color: var(--http-put);
1224-
mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v18"/><path d="m8 8 4-4 4 4"/><path d="m8 16 4 4 4-4"/></svg>');
1224+
mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M7 7h10v10"/><path d="M7 17 17 7"/></svg>');
12251225
}
12261226
nav[aria-label="Main"] a[data-method="put"]:hover::before,
12271227
nav[aria-label="Main"] a[data-method="put"][aria-current="page"]::before {

0 commit comments

Comments
 (0)