@stainless-api/docs 0.1.0-beta.128 → 0.1.0-beta.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.129
4
+
5
+ ### Minor Changes
6
+
7
+ - 966ec34: Fixes nav dropdown logic
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [966ec34]
12
+ - @stainless-api/ui-primitives@0.1.0-beta.52
13
+ - @stainless-api/docs-search@0.1.0-beta.45
14
+ - @stainless-api/docs-ui@0.1.0-beta.92
15
+
3
16
  ## 0.1.0-beta.128
4
17
 
5
18
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.128",
3
+ "version": "0.1.0-beta.129",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -61,9 +61,9 @@
61
61
  "vite-plugin-prebundle-workers": "^0.2.0",
62
62
  "web-worker": "^1.5.0",
63
63
  "yaml": "^2.8.3",
64
- "@stainless-api/docs-search": "0.1.0-beta.44",
65
- "@stainless-api/docs-ui": "0.1.0-beta.91",
66
- "@stainless-api/ui-primitives": "0.1.0-beta.51"
64
+ "@stainless-api/docs-search": "0.1.0-beta.45",
65
+ "@stainless-api/docs-ui": "0.1.0-beta.92",
66
+ "@stainless-api/ui-primitives": "0.1.0-beta.52"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@astrojs/check": "^0.9.8",
@@ -1,29 +1,33 @@
1
1
  ---
2
- import { Dropdown } from '@stainless-api/docs/components';
3
- import { buildNavLinks } from './buildNavLinks';
4
2
  import { ChevronsUpDownIcon } from 'lucide-react';
3
+ import { Dropdown } from '@stainless-api/docs/components';
5
4
 
6
- const navLinks = buildNavLinks(Astro.locals.starlightRoute);
5
+ import type { NavLink } from './buildNavLinks';
7
6
 
8
- const buttonText = (navLinks.find((item) => item.active) ?? navLinks[0]!).label;
7
+ export type Props = {
8
+ links: NavLink[];
9
+ currentItem: NavLink | null;
10
+ };
9
11
  ---
10
12
 
11
13
  <Dropdown id="nav-dropdown" className="nav-dropdown-root">
12
14
  <Dropdown.Trigger>
13
- <Dropdown.TriggerSelectedItem>{buttonText}</Dropdown.TriggerSelectedItem>
15
+ <Dropdown.TriggerSelectedItem>
16
+ {Astro.props.currentItem ? Astro.props.currentItem.label : 'Navigation'}
17
+ </Dropdown.TriggerSelectedItem>
14
18
  <Dropdown.TriggerIcon>
15
19
  <ChevronsUpDownIcon size={16} />
16
20
  </Dropdown.TriggerIcon>
17
21
  </Dropdown.Trigger>
18
22
  <Dropdown.Menu className="dropdown-menu">
19
23
  {
20
- navLinks.map((item) => (
24
+ Astro.props.links.map((item) => (
21
25
  <Dropdown.MenuItem
22
26
  key={item.link}
23
27
  href={item.link}
24
28
  className="dropdown-item"
25
29
  value={item.label}
26
- isSelected={item.label === buttonText}
30
+ isSelected={item.active}
27
31
  >
28
32
  {item.label}
29
33
  <Dropdown.MenuItemTemplate>{item.label}</Dropdown.MenuItemTemplate>
@@ -39,6 +43,7 @@ const buttonText = (navLinks.find((item) => item.active) ?? navLinks[0]!).label;
39
43
 
40
44
  document.addEventListener(getPageLoadEvent(), () => {
41
45
  initDropdown({
46
+ initialValue: null,
42
47
  root: document.getElementById('nav-dropdown'),
43
48
  });
44
49
  });
@@ -5,6 +5,8 @@ import NavDropdown from './NavDropdown.astro';
5
5
  import clsx from 'clsx';
6
6
 
7
7
  const navLinks = buildNavLinks(Astro.locals.starlightRoute);
8
+
9
+ const currentItem = navLinks.find((item) => item.active) ?? null;
8
10
  ---
9
11
 
10
12
  <div id="nav-links-container" class="nav-links-container">
@@ -26,7 +28,7 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
26
28
  </ul>
27
29
  </div>
28
30
  <div class="mobile-nav-dropdown" data-mobile-only>
29
- <NavDropdown />
31
+ {navLinks.length > 0 && <NavDropdown links={navLinks} currentItem={currentItem} />}
30
32
  </div>
31
33
  </div>
32
34
 
@@ -13,3 +13,5 @@ export function buildNavLinks(starlightRoute: StarlightRouteData) {
13
13
 
14
14
  return navLinks;
15
15
  }
16
+
17
+ export type NavLink = ReturnType<typeof buildNavLinks>[number];