CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.
Python agent-frameworkagent-harnessagent-runtimeagentic-aiai-agentsai-frameworkanthropicharnessharness-engineeringharness-frameworklanggraphlanggraph-alternativellmmcpopenaipi-agentpi-agent-corepythonpython-agent
fix(docs): version-aware section links with single-section nav highlight (#119)
Chris969011a23eb4
diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.tsindex 2d6bf4d..922575d 100644--- a/website/docusaurus.config.ts+++ b/website/docusaurus.config.ts@@ -87,9 +87,12 @@ const config: Config = {title: 'CubePi',logo: { alt: 'CubePi logo', src: 'img/brand/cubepi-logo.svg' },items: [- { type: 'doc', docId: 'getting-started/installation', label: 'Docs', position: 'left' },- { type: 'doc', docId: 'api/index', label: 'API', position: 'left' },- { type: 'doc', docId: 'recipes/weather-agent', label: 'Recipes', position: 'left' },+ // Version-aware section links (see src/components/VersionAwareDocLink):+ // active state is path-driven so only one lights up per page, and the+ // target stays within the version the reader is currently browsing.+ { type: 'custom-versionAwareDocLink', section: 'docs', label: 'Docs', position: 'left' },+ { type: 'custom-versionAwareDocLink', section: 'api', label: 'API', position: 'left' },+ { type: 'custom-versionAwareDocLink', section: 'recipes', label: 'Recipes', position: 'left' },{ to: '/changelog', label: 'Changelog', position: 'left' },{ type: 'docsVersionDropdown', position: 'right' },{ type: 'localeDropdown', position: 'right' },diff --git a/website/src/components/VersionAwareDocLink.tsx b/website/src/components/VersionAwareDocLink.tsxnew file mode 100644index 0000000..f661420--- /dev/null+++ b/website/src/components/VersionAwareDocLink.tsx@@ -0,0 +1,53 @@+import React, {type ReactNode} from 'react';+import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';+import type {Props as DefaultNavbarItemProps} from '@theme/NavbarItem/DefaultNavbarItem';+import {+ useActiveDocContext,+ useLatestVersion,+} from '@docusaurus/plugin-content-docs/client';++type Section = 'docs' | 'api' | 'recipes';++// One shared sidebar means a plain `type: 'doc'` item would light up all three+// top-nav links at once. We instead drive the active state from the pathname+// (per-section regex, tolerant of the optional /zh-Hans locale and /docs/0.4/+// version segments) while building a version-aware `to` so clicking stays in+// whatever version the reader is currently browsing.+const SECTIONS: Record<Section, {entry: string; activeBaseRegex: string}> = {+ docs: {+ entry: 'getting-started/installation',+ activeBaseRegex:+ '^(?:/zh-Hans)?/docs/(?!(?:(?:\\d+\\.\\d+|next)/)?(?:api|recipes)(?:/|$))',+ },+ api: {+ entry: 'api/',+ activeBaseRegex: '^(?:/zh-Hans)?/docs/(?:(?:\\d+\\.\\d+|next)/)?api(?:/|$)',+ },+ recipes: {+ entry: 'recipes/weather-agent',+ activeBaseRegex: '^(?:/zh-Hans)?/docs/(?:(?:\\d+\\.\\d+|next)/)?recipes(?:/|$)',+ },+};++type Props = Omit<DefaultNavbarItemProps, 'to' | 'activeBaseRegex'> & {+ section: Section;+};++export default function VersionAwareDocLink({+ section,+ ...props+}: Props): ReactNode {+ const {activeVersion} = useActiveDocContext('default');+ const latestVersion = useLatestVersion('default');+ const version = activeVersion ?? latestVersion;+ const {entry, activeBaseRegex} = SECTIONS[section];+ const base = version.path.replace(/\/$/, '');++ return (+ <DefaultNavbarItem+ {...props}+ to={`${base}/${entry}`}+ activeBaseRegex={activeBaseRegex}+ />+ );+}diff --git a/website/src/theme/NavbarItem/ComponentTypes.tsx b/website/src/theme/NavbarItem/ComponentTypes.tsxnew file mode 100644index 0000000..69d9dd3--- /dev/null+++ b/website/src/theme/NavbarItem/ComponentTypes.tsx@@ -0,0 +1,7 @@+import ComponentTypes from '@theme-original/NavbarItem/ComponentTypes';+import VersionAwareDocLink from '@site/src/components/VersionAwareDocLink';++export default {+ ...ComponentTypes,+ 'custom-versionAwareDocLink': VersionAwareDocLink,+};