diff --git a/assets/js/components/api-tabs.ts b/assets/js/components/api-tabs.ts deleted file mode 100644 index 25b41ec16..000000000 --- a/assets/js/components/api-tabs.ts +++ /dev/null @@ -1,144 +0,0 @@ -/** - * API Tabs Component - * - * Handles tab switching for API reference documentation. - * Uses data-tab and data-tab-panel attributes for explicit panel targeting, - * unlike the generic tabs which use positional indexing. - * - * Features: - * - Explicit panel targeting via data-tab-panel - * - Deep linking via URL hash - * - Browser back/forward navigation support - * - Custom event dispatch for TOC updates - * - * Usage: - *
- *
- * Operations - * Authentication - *
- *
- *
- *
...
- *
...
- *
- */ - -interface ComponentOptions { - component: HTMLElement; -} - -/** - * Find the panels container (sibling element after tabs) - */ -function findPanelsContainer(tabsWrapper: HTMLElement): HTMLElement | null { - let sibling = tabsWrapper.nextElementSibling; - while (sibling) { - if (sibling.classList.contains('api-tab-panels')) { - return sibling as HTMLElement; - } - sibling = sibling.nextElementSibling; - } - return null; -} - -/** - * Switch to a specific tab - */ -function switchTab( - tabsWrapper: HTMLElement, - panelsContainer: HTMLElement, - tabId: string, - updateHash = true -): void { - // Update active tab - const tabs = tabsWrapper.querySelectorAll('[data-tab]'); - tabs.forEach((tab) => { - if (tab.dataset.tab === tabId) { - tab.classList.add('is-active'); - } else { - tab.classList.remove('is-active'); - } - }); - - // Update visible panel - const panels = - panelsContainer.querySelectorAll('[data-tab-panel]'); - panels.forEach((panel) => { - if (panel.dataset.tabPanel === tabId) { - panel.style.display = 'block'; - } else { - panel.style.display = 'none'; - } - }); - - // Update URL hash without scrolling - if (updateHash) { - history.replaceState(null, '', '#' + tabId); - } - - // Dispatch custom event for TOC update - document.dispatchEvent( - new CustomEvent('api-tab-change', { detail: { tab: tabId } }) - ); -} - -/** - * Get tab ID from URL hash - */ -function getTabFromHash(): string | null { - const hash = window.location.hash.substring(1); - return hash || null; -} - -/** - * Initialize API Tabs component - */ -export default function ApiTabs({ component }: ComponentOptions): void { - const panelsContainer = findPanelsContainer(component); - - if (!panelsContainer) { - console.warn('[API Tabs] No .api-tab-panels container found'); - return; - } - - const tabs = component.querySelectorAll('[data-tab]'); - - if (tabs.length === 0) { - console.warn('[API Tabs] No tabs found with data-tab attribute'); - return; - } - - // Handle tab clicks - tabs.forEach((tab) => { - tab.addEventListener('click', (e) => { - e.preventDefault(); - e.stopPropagation(); // Prevent other tab handlers from firing - - const tabId = tab.dataset.tab; - if (tabId) { - switchTab(component, panelsContainer, tabId); - } - }); - }); - - // Handle deep linking via URL hash on load - const hashTab = getTabFromHash(); - if (hashTab) { - const matchingTab = component.querySelector(`[data-tab="${hashTab}"]`); - if (matchingTab) { - switchTab(component, panelsContainer, hashTab, false); - } - } - - // Handle browser back/forward navigation - window.addEventListener('hashchange', () => { - const newTabId = getTabFromHash(); - if (newTabId) { - const matchingTab = component.querySelector(`[data-tab="${newTabId}"]`); - if (matchingTab) { - switchTab(component, panelsContainer, newTabId, false); - } - } - }); -} diff --git a/assets/js/main.js b/assets/js/main.js index c703d6309..77fda067a 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -47,7 +47,6 @@ import { SidebarToggle } from './sidebar-toggle.js'; import Theme from './theme.js'; import ThemeSwitch from './theme-switch.js'; import ApiRapiDoc from './components/api-rapidoc.ts'; -import ApiTabs from './components/api-tabs.ts'; import ApiToc from './components/api-toc.ts'; import RapiDocMini from './components/rapidoc-mini.ts'; @@ -82,7 +81,6 @@ const componentRegistry = { theme: Theme, 'theme-switch': ThemeSwitch, 'api-rapidoc': ApiRapiDoc, - 'api-tabs': ApiTabs, 'api-toc': ApiToc, 'rapidoc-mini': RapiDocMini, }; diff --git a/layouts/partials/api/tab-panels.html b/layouts/partials/api/tab-panels.html deleted file mode 100644 index 68d28973c..000000000 --- a/layouts/partials/api/tab-panels.html +++ /dev/null @@ -1,31 +0,0 @@ -{{/* - API Reference Tab Panels (DEPRECATED) - - This partial is kept for backward compatibility. - The new architecture renders content directly in layouts: - - layouts/api/list.html: Tag pages with operations list - - layouts/api/single.html: Individual operation pages with RapiDoc - - For conceptual pages (isConceptual: true), renders tag description content. - For operational pages, renders the API documentation via RapiDoc. -*/}} - -{{ $isConceptual := .Params.isConceptual | default false }} - -{{ if $isConceptual }} -{{/* Conceptual Page - Display tag description content only */}} -
- {{ with .Content }} - {{ . }} - {{ else }} - {{ with .Params.tagDescription }} - {{ . | markdownify }} - {{ end }} - {{ end }} -
-{{ else }} -{{/* Operations Page - RapiDoc renderer */}} -
- {{ partial "api/rapidoc.html" . }} -
-{{ end }} diff --git a/layouts/partials/api/tabs.html b/layouts/partials/api/tabs.html deleted file mode 100644 index a33099cc0..000000000 --- a/layouts/partials/api/tabs.html +++ /dev/null @@ -1,10 +0,0 @@ -{{/* - API Reference Page Tabs (DEPRECATED) - - This partial is kept for backward compatibility but renders nothing. - The new architecture uses: - - Tag pages (list.html): Display operations list directly - - Operation pages (single.html): Display RapiDoc for single operation -*/}} - -{{/* No tabs rendered - using simplified layout */}}