@stainless-api/docs 0.1.0-beta.5 → 0.1.0-beta.7

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/components/variables.css +0 -4
  4. package/package.json +5 -4
  5. package/plugin/components/search/SearchAlgolia.astro +0 -7
  6. package/plugin/globalJs/navigation.ts +0 -23
  7. package/plugin/helpers/getPageLoadEvent.ts +1 -1
  8. package/plugin/react/Routing.tsx +13 -22
  9. package/plugin/routes/Docs.astro +3 -5
  10. package/stl-docs/components/Header.astro +1 -1
  11. package/stl-docs/components/ThemeSelect.astro +1 -6
  12. package/stl-docs/components/content-panel/ContentBreadcrumbs.tsx +16 -8
  13. package/stl-docs/components/content-panel/ContentPanel.astro +5 -26
  14. package/stl-docs/components/headers/DefaultHeader.astro +1 -1
  15. package/stl-docs/components/headers/HeaderLinks.astro +1 -1
  16. package/stl-docs/components/headers/StackedHeader.astro +1 -1
  17. package/stl-docs/components/mintlify-compat/Accordion.astro +5 -38
  18. package/stl-docs/components/mintlify-compat/AccordionGroup.astro +6 -24
  19. package/stl-docs/components/mintlify-compat/callouts/Callout.astro +10 -3
  20. package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -3
  21. package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -3
  22. package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -3
  23. package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -3
  24. package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -3
  25. package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -3
  26. package/stl-docs/components/nav-tabs/NavDropdown.astro +1 -6
  27. package/stl-docs/components/nav-tabs/buildNavLinks.ts +1 -1
  28. package/stl-docs/components/{Sidebar.astro → sidebars/BaseSidebar.astro} +2 -3
  29. package/stl-docs/components/sidebars/SDKSelectSidebar.astro +8 -0
  30. package/stl-docs/index.ts +16 -4
  31. package/stl-docs/loadStlDocsConfig.ts +2 -2
  32. package/stl-docs/tabsMiddleware.ts +1 -1
  33. package/styles/overrides.css +4 -0
  34. package/styles/page.css +0 -9
  35. package/theme.css +11 -1
  36. package/virtual-module.d.ts +1 -1
  37. package/plugin/globalJs/ai-dropdown.ts +0 -57
  38. package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -86
  39. package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -64
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @stainless-api/docs
2
2
 
3
+ ## 0.1.0-beta.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [34e7c61]
8
+ - @stainless-api/ui-primitives@0.1.0-beta.7
9
+ - @stainless-api/docs-ui@0.1.0-beta.6
10
+
11
+ ## 0.1.0-beta.6
12
+
13
+ ### Patch Changes
14
+
15
+ - 34cbd12: verify publishing
16
+ - Updated dependencies [f664b4d]
17
+ - Updated dependencies [34cbd12]
18
+ - @stainless-api/ui-primitives@0.1.0-beta.6
19
+ - @stainless-api/docs-ui@0.1.0-beta.5
20
+
3
21
  ## 0.1.0-beta.5
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  3. In your Astro config:
6
6
 
7
7
  ```
8
- import { stainlessStarlight } from "@stainless-api/docs";
8
+ import { stainlessStarlight } from "stl-starlight";
9
9
  ```
10
10
 
11
11
  4. Run `pnpm astro:sync` to generate astro types
@@ -1,7 +1,4 @@
1
1
  :root {
2
- --sl-font: 'Geist', system-ui, sans-serif;
3
- --sl-font-mono: 'Geist Mono', ui-monospace, monospace;
4
-
5
2
  --stldocs-font: var(--sl-font, system-ui, sans-serif);
6
3
  --stldocs-font-mono: var(--sl-font-mono, ui-monospace, monospace);
7
4
 
@@ -78,7 +75,6 @@
78
75
  /* UI Overrides */
79
76
  --stl-ui-button-border-radius: var(--sl-button-border-radius);
80
77
  --stl-ui-text-body: var(--sl-text-sm);
81
- --stl-ui-font-family: var(--sl-font);
82
78
  --stl-ui-button-size: var(--sl-button-size);
83
79
 
84
80
  --stl-ui-color-accent-low: var(--sl-color-accent-low);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stainless-api/docs",
3
- "version": "0.1.0-beta.5",
3
+ "version": "0.1.0-beta.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -19,7 +19,8 @@
19
19
  "./stainless-docs": "./stl-docs/index.ts",
20
20
  "./Header": "./stl-docs/components/Header.astro",
21
21
  "./ThemeSelect": "./stl-docs/components/ThemeSelect.astro",
22
- "./Sidebar": "./stl-docs/components/Sidebar.astro",
22
+ "./BaseSidebar": "./stl-docs/components/sidebars/BaseSidebar.astro",
23
+ "./SDKSelectSidebar": "./stl-docs/components/sidebars/SDKSelectSidebar.astro",
23
24
  "./ContentPanel": "./stl-docs/components/content-panel/ContentPanel.astro",
24
25
  "./tabsMiddleware": "./stl-docs/tabsMiddleware.ts",
25
26
  "./stainless-docs/mintlify-compat": "./stl-docs/components/mintlify-compat/index.ts",
@@ -54,8 +55,8 @@
54
55
  "shiki": "^3.9.2",
55
56
  "web-worker": "^1.5.0",
56
57
  "yaml": "^2.8.0",
57
- "@stainless-api/docs-ui": "0.1.0-beta.4",
58
- "@stainless-api/ui-primitives": "0.1.0-beta.5"
58
+ "@stainless-api/docs-ui": "0.1.0-beta.6",
59
+ "@stainless-api/ui-primitives": "0.1.0-beta.7"
59
60
  },
60
61
  "devDependencies": {
61
62
  "@markdoc/markdoc": "^0.5.2",
@@ -2,13 +2,6 @@
2
2
  import { Icon } from '@astrojs/starlight/components';
3
3
  import { DocsSearch } from './SearchIsland';
4
4
  import { SEARCH } from 'virtual:stl-starlight-virtual-module';
5
-
6
- import '@stainless-api/docs-ui/src/styles/resets.css';
7
- import '@stainless-api/docs-ui/src/styles/primitives.css';
8
- import '@stainless-api/docs-ui/src/styles/main.css';
9
- import '@stainless-api/docs-ui/src/styles/snippets.css';
10
- import '@stainless-api/docs-ui/src/styles/search.css';
11
- import '../../../components/variables.css';
12
5
  ---
13
6
 
14
7
  <site-search>
@@ -5,8 +5,6 @@ import { navigate } from 'astro:transitions/client';
5
5
  import { getPageLoadEvent } from '../helpers/getPageLoadEvent.ts';
6
6
 
7
7
  import { initDropdown } from '@stainless-api/docs-ui/src/components/scripts/dropdown';
8
- import { initDropdownButton } from '@stainless-api/ui-primitives/scripts';
9
- import { copyCurrentPageAsMarkdown, onSelectAIOption } from './ai-dropdown.ts';
10
8
 
11
9
  history.scrollRestoration = 'auto';
12
10
 
@@ -36,27 +34,6 @@ document.addEventListener(getPageLoadEvent(), () => {
36
34
  if (path) setTimeout(() => scrollToPath(path.slice(1)), 10);
37
35
  });
38
36
 
39
- document.addEventListener(getPageLoadEvent(), () => {
40
- console.log('Initializing AI Dropdown');
41
- initDropdownButton({
42
- dropdownId: 'ai-dropdown-button',
43
- onSelect: onSelectAIOption,
44
- onPrimaryAction: (el) => {
45
- copyCurrentPageAsMarkdown();
46
- const innerText = el.querySelector('[data-part="primary-action-text"]');
47
- if (!innerText) return;
48
-
49
- const originalInnerHtml = innerText.innerHTML;
50
- innerText.innerHTML = 'Copied!';
51
- el.classList.add('disabled');
52
- setTimeout(() => {
53
- innerText.innerHTML = originalInnerHtml;
54
- el.classList.remove('disabled');
55
- }, 1000);
56
- },
57
- });
58
- });
59
-
60
37
  document.addEventListener('click', (event) => {
61
38
  const toggle = (event.target as HTMLElement).closest(
62
39
  '[data-stldocs-property-toggle-expanded] > .stldocs-expand-toggle-content',
@@ -1,4 +1,4 @@
1
- // import { ENABLE_CLIENT_ROUTER } from 'virtual:stl-stl-starlight-virtual-module';
1
+ // import { ENABLE_CLIENT_ROUTER } from 'virtual:stl-docs-virtual-module';
2
2
 
3
3
  export function getPageLoadEvent() {
4
4
  // if (ENABLE_CLIENT_ROUTER) {
@@ -55,7 +55,6 @@ import { SnippetCode, SnippetContainer, SnippetRequestContainer } from '../compo
55
55
  import clsx from 'clsx';
56
56
  import type { StlStarlightMiddleware } from '../middlewareBuilder/stainlessMiddleware';
57
57
  import { ComponentProvider } from '@stainless-api/docs-ui/src/contexts/component';
58
- import { APIReferenceAIDropdown } from '../../stl-docs/components/APIReferenceAIDropdown';
59
58
 
60
59
  export function generateDocsRoutes(spec: SDKJSON.Spec) {
61
60
  const paths = generateRouteList({
@@ -325,15 +324,12 @@ export function RenderSpec({
325
324
  <MarkdownProvider render={renderMarkdown} highlight={highlight}>
326
325
  {kind === 'http_method' ? (
327
326
  <div className="stldocs-root stl-ui-not-prose">
328
- <div className="stl-page-nav-container">
329
- <SDKBreadcrumbs
330
- spec={spec as SDKJSON.Spec}
331
- currentPath={currentPath}
332
- basePath={BASE_PATH}
333
- config={BREADCRUMB_CONFIG}
334
- />
335
- <APIReferenceAIDropdown />
336
- </div>
327
+ <SDKBreadcrumbs
328
+ spec={spec as SDKJSON.Spec}
329
+ currentPath={currentPath}
330
+ basePath={BASE_PATH}
331
+ config={BREADCRUMB_CONFIG}
332
+ />
337
333
  <SDKMethod
338
334
  method={resource.methods[parsed.method]}
339
335
  transformRequestSnippet={transformRequestSnippet}
@@ -341,15 +337,12 @@ export function RenderSpec({
341
337
  </div>
342
338
  ) : (
343
339
  <div className="stldocs-root stl-ui-not-prose">
344
- <div className="stl-page-nav-container">
345
- <SDKBreadcrumbs
346
- spec={spec as SDKJSON.Spec}
347
- currentPath={currentPath}
348
- basePath={BASE_PATH}
349
- config={BREADCRUMB_CONFIG}
350
- />
351
- <APIReferenceAIDropdown />
352
- </div>
340
+ <SDKBreadcrumbs
341
+ spec={spec as SDKJSON.Spec}
342
+ currentPath={currentPath}
343
+ basePath={BASE_PATH}
344
+ config={BREADCRUMB_CONFIG}
345
+ />
353
346
  <SDKOverview resource={resource} />
354
347
  </div>
355
348
  )}
@@ -382,9 +375,7 @@ export async function getReadmeContent(spec: SDKJSON.Spec, language: DocsLanguag
382
375
  const response = await fetch(`${rawUrl}/refs/heads/main/README.md`);
383
376
  if (response && response.ok) return response.text();
384
377
  }
385
- } catch {
386
- // ignore
387
- }
378
+ } catch (err) {}
388
379
 
389
380
  return spec.readme[language];
390
381
  }
@@ -119,12 +119,10 @@ if (readme) {
119
119
  .content-panel:nth-of-type(1) {
120
120
  display: none;
121
121
  }
122
- .content-panel:nth-of-type(2) .stl-page-nav-container {
123
- display: none;
124
- }
125
122
 
126
- .content-panel:nth-of-type(2) .stldocs-root .stl-page-nav-container {
127
- display: flex;
123
+ .content-panel:nth-of-type(2) {
124
+ border: none;
125
+ padding: 0;
128
126
  }
129
127
  </style>
130
128
  </div>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import config from 'virtual:starlight/user-config';
3
3
 
4
- import { HEADER_LAYOUT } from 'virtual:stl-stl-starlight-virtual-module';
4
+ import { HEADER_LAYOUT } from 'virtual:stl-docs-virtual-module';
5
5
  import DefaultHeader from './headers/DefaultHeader.astro';
6
6
  import StackedHeader from './headers/StackedHeader.astro';
7
7
 
@@ -1,10 +1,5 @@
1
1
  ---
2
- import {
3
- Dropdown,
4
- DropdownTrigger,
5
- DropdownMenu,
6
- DropdownItem,
7
- } from '@stainless-api/docs-ui/src/components/dropdown';
2
+ import { Dropdown, DropdownTrigger, DropdownMenu, DropdownItem } from '@stainless-api/docs-ui/src/components/dropdown';
8
3
 
9
4
  const options = [
10
5
  {
@@ -5,22 +5,25 @@ import type { StarlightRouteData } from '@astrojs/starlight/route-data';
5
5
 
6
6
  type Breadcrumb = { title: string; href: string };
7
7
 
8
+ // because this component is used in Stainless Docs and stl-starlight, we need to conditionally import the BASE_PATH from the virtual module
9
+ let basePath: string | null = null;
10
+ try {
11
+ const mod = await import('virtual:stl-starlight-virtual-module');
12
+ basePath = mod.BASE_PATH;
13
+ // eslint-disable-next-line no-empty, @typescript-eslint/no-unused-vars
14
+ } catch (_e) {}
15
+
8
16
  // Normalize paths to avoid mismatches due to trailing slashes
9
17
  function normalizePath(path: string) {
10
18
  return path.endsWith('/') ? path : path + '/';
11
19
  }
12
20
 
13
- export function findBreadcrumbTrail(
14
- sidebarEntry: StarlightRouteData['sidebar'],
21
+ function findBreadcrumbTrail(
22
+ entries: StarlightRouteData['sidebar'],
15
23
  targetPath: string,
16
24
  includeCurrentPage: boolean,
17
25
  trail: Breadcrumb[] = [],
18
26
  ): Breadcrumb[] | null {
19
- const entries = sidebarEntry.filter((entry) => {
20
- return !(
21
- entry as StarlightRouteData['sidebar'][number] & { attrs?: { class?: string } }
22
- ).attrs?.class?.includes('stl-mobile-only-sidebar-item');
23
- });
24
27
  const normalizedTarget = normalizePath(targetPath);
25
28
 
26
29
  for (const entry of entries) {
@@ -54,7 +57,12 @@ export function ContentBreadcrumbs({
54
57
  currentPath: string;
55
58
  sidebarEntry: StarlightRouteData['sidebar'];
56
59
  }) {
57
- const breadcrumbs = findBreadcrumbTrail(sidebarEntry, currentPath, true);
60
+ if (basePath && currentPath.startsWith(basePath)) {
61
+ return null;
62
+ }
63
+
64
+ const entryWithoutTopLevelLinks = sidebarEntry.filter((entry) => entry.type !== 'link');
65
+ const breadcrumbs = findBreadcrumbTrail(entryWithoutTopLevelLinks, currentPath, true);
58
66
 
59
67
  if (!breadcrumbs) {
60
68
  return null;
@@ -1,14 +1,12 @@
1
1
  ---
2
2
  import { ContentBreadcrumbs } from './ContentBreadcrumbs';
3
- import { ProseAIDropdown } from './ProseAIDropdown';
4
3
  const currentPath = Astro.url.pathname;
5
4
  ---
6
5
 
7
6
  <div class="content-panel">
8
7
  <div class="sl-container stl-ui-prose">
9
- <div class="stl-ui-not-prose stl-page-nav-container stl-prose-page-nav-container">
8
+ <div class="stl-ui-not-prose">
10
9
  <ContentBreadcrumbs currentPath={currentPath} sidebarEntry={Astro.locals.starlightRoute.sidebar} />
11
- <ProseAIDropdown currentPath={currentPath} sidebarEntry={Astro.locals.starlightRoute.sidebar} />
12
10
  </div>
13
11
  <slot />
14
12
  </div>
@@ -41,32 +39,13 @@ const currentPath = Astro.url.pathname;
41
39
  .content-panel {
42
40
  padding: 0 var(--sl-content-pad-x);
43
41
  }
44
-
45
- .stl-prose-page-nav-container {
46
- padding: 1rem 0 0;
47
- }
48
42
  }
49
43
  </style>
50
44
 
51
45
  <style is:global>
52
- .content-panel:nth-of-type(2) .stl-page-nav-container {
53
- display: none;
46
+ main .content-panel:not(:first-of-type) {
47
+ .stl-content-breadcrumbs {
48
+ display: none;
49
+ }
54
50
  }
55
51
  </style>
56
-
57
- <script>
58
- import { initDropdownButton } from '@stainless-api/ui-primitives/scripts';
59
- import { getPageLoadEvent } from '../../../plugin/helpers/getPageLoadEvent';
60
- import { onSelectAIOption } from '../../../plugin/globalJs/ai-dropdown.ts';
61
-
62
- document.addEventListener(getPageLoadEvent(), () => {
63
- console.log('Initializing AI Dropdown');
64
- initDropdownButton({
65
- dropdownId: 'prose-ai-dropdown-button',
66
- onSelect: (option: string) => onSelectAIOption(option, false),
67
- onPrimaryAction: () => {
68
- onSelectAIOption('claude', false);
69
- },
70
- });
71
- });
72
- </script>
@@ -4,7 +4,7 @@ import Search from 'virtual:starlight/components/Search';
4
4
  import SiteTitle from 'virtual:starlight/components/SiteTitle';
5
5
  import HeaderLinks from './HeaderLinks.astro';
6
6
  import NavLinks from '../nav-tabs/NavTabs.astro';
7
- import { TABS } from 'virtual:stl-stl-starlight-virtual-module';
7
+ import { TABS } from 'virtual:stl-docs-virtual-module';
8
8
  import ThemeSelect from 'virtual:starlight/components/ThemeSelect';
9
9
  import SplashMobileMenuToggle from './SplashMobileMenuToggle.astro';
10
10
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- import { HEADER_LINKS } from 'virtual:stl-stl-starlight-virtual-module';
2
+ import { HEADER_LINKS } from 'virtual:stl-docs-virtual-module';
3
3
  import { Button } from '@stainless-api/ui-primitives';
4
4
  ---
5
5
 
@@ -3,7 +3,7 @@ import LanguageSelect from "virtual:starlight/components/LanguageSelect";
3
3
  import Search from "virtual:starlight/components/Search";
4
4
  import SiteTitle from "virtual:starlight/components/SiteTitle";
5
5
  import HeaderLinks from './HeaderLinks.astro';
6
- import { TABS } from "virtual:stl-stl-starlight-virtual-module";
6
+ import { TABS } from "virtual:stl-docs-virtual-module";
7
7
  import ThemeSelect from "virtual:starlight/components/ThemeSelect";
8
8
  import SecondaryNavTabs from "../nav-tabs/SecondaryNavTabs.astro";
9
9
  import SplashMobileMenuToggle from "./SplashMobileMenuToggle.astro";
@@ -1,46 +1,13 @@
1
1
  ---
2
2
  export interface Props {
3
- title: string;
3
+ title: unknown;
4
+ children: unknown;
4
5
  }
5
6
 
6
7
  const { title } = Astro.props;
7
8
  ---
8
9
 
9
- <details class="stl-ui-mintlify-compat-accordion" role="button" data-stl-ui-element>
10
- <summary class="stl-ui-mintlify-compat-accordion-title">{title}</summary>
11
- <div class="stl-ui-mintlify-compat-accordion-content" role="contentinfo">
12
- <slot />
13
- </div>
10
+ <details>
11
+ <summary>{title}</summary>
12
+ <slot />
14
13
  </details>
15
-
16
- <style>
17
- @layer stl-ui-mintlify-compat {
18
- .stl-ui-mintlify-compat-accordion {
19
- border-inline-start: none;
20
- padding-inline-start: 0;
21
- border-radius: 12px;
22
- border: 1px solid var(--sl-color-hairline);
23
- overflow: hidden;
24
-
25
- summary {
26
- padding: 16px;
27
- margin-inline-start: 0;
28
- overflow: hidden;
29
-
30
- &:hover {
31
- background-color: var(--sl-color-hairline);
32
- }
33
- }
34
-
35
- .stl-ui-mintlify-compat-accordion-title {
36
- display: flex;
37
- align-items: center;
38
- gap: 8px;
39
- }
40
-
41
- .stl-ui-mintlify-compat-accordion-content {
42
- padding: 16px;
43
- }
44
- }
45
- }
46
- </style>
@@ -1,25 +1,7 @@
1
- <div class="stl-ui-mintlify-compat-accordion-group">
2
- <slot />
3
- </div>
4
-
5
- <style>
6
- @layer stl-ui-mintlify-compat {
7
- .stl-ui-mintlify-compat-accordion-group {
8
- border-radius: 12px;
9
- border: 1px solid var(--sl-color-hairline);
10
- overflow: hidden;
11
- padding-inline-start: -5rem;
1
+ ---
2
+ import { DetailsGroup } from '@stainless-api/ui-primitives';
3
+ ---
12
4
 
13
- .stl-ui-mintlify-compat-accordion {
14
- margin: 0;
15
- border-inline-start: none;
16
- border: none;
17
- border-radius: 0;
18
-
19
- &:not(:last-child) {
20
- border-bottom: 1px solid var(--sl-color-hairline);
21
- }
22
- }
23
- }
24
- }
25
- </style>
5
+ <DetailsGroup>
6
+ <slot />
7
+ </DetailsGroup>
@@ -1,7 +1,14 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout as StainlessCallout, type CalloutVariant } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ variant?: CalloutVariant;
6
+ children: unknown;
7
+ }
8
+
9
+ const { variant } = Astro.props;
3
10
  ---
4
11
 
5
- <Aside>
12
+ <StainlessCallout variant={variant}>
6
13
  <slot />
7
- </Aside>
14
+ </StainlessCallout>
@@ -1,7 +1,11 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ children: unknown;
6
+ }
3
7
  ---
4
8
 
5
- <Aside>
9
+ <Callout variant="success">
6
10
  <slot />
7
- </Aside>
11
+ </Callout>
@@ -1,7 +1,11 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ children: unknown;
6
+ }
3
7
  ---
4
8
 
5
- <Aside type="danger">
9
+ <Callout variant="danger">
6
10
  <slot />
7
- </Aside>
11
+ </Callout>
@@ -1,7 +1,11 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ children: unknown;
6
+ }
3
7
  ---
4
8
 
5
- <Aside>
9
+ <Callout variant="info">
6
10
  <slot />
7
- </Aside>
11
+ </Callout>
@@ -1,7 +1,11 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ children: unknown;
6
+ }
3
7
  ---
4
8
 
5
- <Aside>
9
+ <Callout variant="note">
6
10
  <slot />
7
- </Aside>
11
+ </Callout>
@@ -1,7 +1,11 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ children: unknown;
6
+ }
3
7
  ---
4
8
 
5
- <Aside type="tip">
9
+ <Callout variant="tip">
6
10
  <slot />
7
- </Aside>
11
+ </Callout>
@@ -1,7 +1,11 @@
1
1
  ---
2
- import { Aside } from '@astrojs/starlight/components';
2
+ import { Callout } from '@stainless-api/ui-primitives';
3
+
4
+ export interface Props {
5
+ children: unknown;
6
+ }
3
7
  ---
4
8
 
5
- <Aside type="caution">
9
+ <Callout variant="warning">
6
10
  <slot />
7
- </Aside>
11
+ </Callout>
@@ -1,10 +1,5 @@
1
1
  ---
2
- import {
3
- Dropdown,
4
- DropdownTrigger,
5
- DropdownMenu,
6
- DropdownItem,
7
- } from '@stainless-api/docs-ui/src/components/dropdown';
2
+ import { Dropdown, DropdownTrigger, DropdownMenu, DropdownItem } from '@stainless-api/docs-ui/src/components/dropdown';
8
3
  import { Icon } from '@astrojs/starlight/components';
9
4
  import { buildNavLinks } from './buildNavLinks';
10
5
 
@@ -1,5 +1,5 @@
1
1
  import type { StarlightRouteData } from '@astrojs/starlight/route-data';
2
- import { TABS } from 'virtual:stl-stl-starlight-virtual-module';
2
+ import { TABS } from 'virtual:stl-docs-virtual-module';
3
3
 
4
4
  export function buildNavLinks(starlightRoute: StarlightRouteData) {
5
5
  // TODO: specify the type of Astro.locals.starlightRoute._stlStarlight
@@ -1,11 +1,10 @@
1
1
  ---
2
2
  import Default from '@astrojs/starlight/components/Sidebar.astro';
3
- import SDKSelect from '../../plugin/components/SDKSelect.astro';
4
- import HeaderLinks from './headers/HeaderLinks.astro';
3
+ import HeaderLinks from '../headers/HeaderLinks.astro';
5
4
  ---
6
5
 
7
6
  <div class="stl-sidebar-header-links">
8
7
  <HeaderLinks />
9
8
  </div>
10
- <SDKSelect />
9
+ <slot name="sdk-select" />
11
10
  <Default><slot /></Default>
@@ -0,0 +1,8 @@
1
+ ---
2
+ import BaseSidebar from './BaseSidebar.astro';
3
+ import SDKSelect from '../../../plugin/components/SDKSelect.astro';
4
+ ---
5
+
6
+ <BaseSidebar>
7
+ <SDKSelect slot="sdk-select" />
8
+ </BaseSidebar>
package/stl-docs/index.ts CHANGED
@@ -40,14 +40,21 @@ function stainlessDocsStarlightIntegration(config: NormalizedStainlessDocsConfig
40
40
  }
41
41
 
42
42
  type ComponentOverrides = StarlightConfigDefined['components'];
43
+ const plugins = [...config.starlightCompat.plugins];
44
+
43
45
  const componentOverrides: ComponentOverrides = {
44
- Search: '@stainless-api/docs/Search',
45
- Sidebar: '@stainless-api/docs/Sidebar',
46
+ Sidebar: '@stainless-api/docs/BaseSidebar',
46
47
  Header: '@stainless-api/docs/Header',
47
48
  ThemeSelect: '@stainless-api/docs/ThemeSelect',
48
49
  ContentPanel: '@stainless-api/docs/ContentPanel',
49
50
  };
50
51
 
52
+ if (config.apiReference !== null) {
53
+ componentOverrides.Sidebar = '@stainless-api/docs/SDKSelectSidebar';
54
+ componentOverrides.Search = '@stainless-api/docs/Search';
55
+ plugins.unshift(stainlessStarlight(config.apiReference));
56
+ }
57
+
51
58
  // TODO: re-add once we figure out what to do with the client router
52
59
  // if (config.enableClientRouter) {
53
60
  // // logger.info(`Client router is enabled`);
@@ -94,12 +101,12 @@ function stainlessDocsStarlightIntegration(config: NormalizedStainlessDocsConfig
94
101
  ],
95
102
  routeMiddleware: [...config.starlightCompat.routeMiddleware, '@stainless-api/docs/tabsMiddleware'],
96
103
  customCss: ['@stainless-api/docs/theme', ...config.customCss],
97
- plugins: [stainlessStarlight(config.apiReference), ...config.starlightCompat.plugins],
104
+ plugins,
98
105
  });
99
106
  }
100
107
 
101
108
  function stainlessDocsIntegration(config: NormalizedStainlessDocsConfig): AstroIntegration {
102
- const virtualId = `virtual:stl-stl-starlight-virtual-module`;
109
+ const virtualId = `virtual:stl-docs-virtual-module`;
103
110
  // The '\0' prefix tells Vite “this is a virtual module” and prevents it from being resolved again.
104
111
  const resolvedId = `\0${virtualId}`;
105
112
  let redirects: NormalizedRedirectConfig | null = null;
@@ -116,6 +123,10 @@ function stainlessDocsIntegration(config: NormalizedStainlessDocsConfig): AstroI
116
123
 
117
124
  updateConfig({
118
125
  vite: {
126
+ ssr: {
127
+ noExternal: ['@stainless-api/ui-primitives'],
128
+ },
129
+ optimizeDeps: { include: ['@stainless-api/ui-primitives'] },
119
130
  plugins: [
120
131
  {
121
132
  name: 'stl-docs-vite',
@@ -166,6 +177,7 @@ export function stainlessDocs(config: StainlessDocsUserConfig) {
166
177
  process.exit(1);
167
178
  }
168
179
  const normalizedConfig = normalizedConfigResult.config;
180
+
169
181
  return [
170
182
  react(),
171
183
  stainlessDocsStarlightIntegration(normalizedConfig),
@@ -58,7 +58,7 @@ export type HeaderLink = {
58
58
  };
59
59
 
60
60
  export type StainlessDocsUserConfig = {
61
- apiReference: StainlessStarlightUserConfig;
61
+ apiReference?: StainlessStarlightUserConfig;
62
62
  tabs?: Tabs;
63
63
  header?: {
64
64
  layout?: HeaderLayout;
@@ -126,7 +126,7 @@ function normalizeConfig(userConfig: StainlessDocsUserConfig) {
126
126
  routeMiddleware: normalizeRouteMiddleware(userConfig),
127
127
  },
128
128
  enableClientRouter: userConfig.experimental?.enableClientRouter ?? false,
129
- apiReference: userConfig.apiReference,
129
+ apiReference: userConfig.apiReference ?? null,
130
130
  sidebar: userConfig.sidebar,
131
131
  };
132
132
 
@@ -1,7 +1,7 @@
1
1
  import type { StarlightRouteData } from '@astrojs/starlight/route-data';
2
2
  import { defineRouteMiddleware } from '@astrojs/starlight/route-data';
3
3
 
4
- import { SPLIT_TABS_ENABLED, TABS } from 'virtual:stl-stl-starlight-virtual-module';
4
+ import { SPLIT_TABS_ENABLED, TABS } from 'virtual:stl-docs-virtual-module';
5
5
  import clsx from 'clsx';
6
6
 
7
7
  // this fn is loaded in the plugin via addRouteMiddleware
@@ -19,6 +19,10 @@
19
19
  overflow: hidden;
20
20
  }
21
21
 
22
+ button {
23
+ border-radius: var(--sl-button-border-radius);
24
+ }
25
+
22
26
  .custom-select-wrapper select,
23
27
  .stldocs-button-secondary {
24
28
  background-color: var(--sl-color-bg-ui);
package/styles/page.css CHANGED
@@ -58,15 +58,6 @@
58
58
  padding-left: 0;
59
59
  }
60
60
  }
61
-
62
- .stl-page-nav-container {
63
- display: flex;
64
- align-items: center;
65
- justify-content: space-between;
66
- gap: 1rem;
67
- padding: 1rem 1rem 0;
68
- flex-wrap: wrap;
69
- }
70
61
  }
71
62
 
72
63
  @media (min-width: 50em) {
package/theme.css CHANGED
@@ -1,5 +1,7 @@
1
1
  @layer starlight.base, starlight.reset, starlight.core, starlight.content, starlight.components, starlight.utils;
2
- @layer starlight, docs-ui, stl-ui, stainless;
2
+ @layer starlight;
3
+ @layer stl-ui.starlight-compat, stl-ui.typography, stl-ui.components;
4
+ @layer stl-ui, docs-ui, stainless;
3
5
 
4
6
  @import './styles/fonts.css';
5
7
  @import './styles/variables.css';
@@ -13,3 +15,11 @@
13
15
  @import './styles/sdk_select.css';
14
16
  @import '@stainless-api/ui-primitives/styles.css';
15
17
  @import './styles/mintlify-compat.css';
18
+
19
+ @import '@stainless-api/docs-ui/src/styles/resets.css';
20
+ @import '@stainless-api/docs-ui/src/styles/primitives.css';
21
+ @import '@stainless-api/docs-ui/src/styles/main.css';
22
+ @import '@stainless-api/docs-ui/src/styles/snippets.css';
23
+ @import '@stainless-api/docs-ui/src/styles/search.css';
24
+
25
+ @import './components/variables.css';
@@ -20,7 +20,7 @@ declare module 'virtual:stl-starlight-virtual-module' {
20
20
  export const SEARCH: StainlessStarlightUserConfig['search'];
21
21
  }
22
22
 
23
- declare module 'virtual:stl-stl-starlight-virtual-module' {
23
+ declare module 'virtual:stl-docs-virtual-module' {
24
24
  import type { ButtonVariant } from '@stainless-api/ui-primitives';
25
25
  import type { AnchorHTMLAttributes } from 'react';
26
26
 
@@ -1,57 +0,0 @@
1
- export const copyCurrentPageAsMarkdown = async () => {
2
- const currentUrl = new URL(window.location.href);
3
- const markdownUrl = `${currentUrl.origin}${currentUrl.pathname}.md`;
4
-
5
- try {
6
- const response = await fetch(markdownUrl);
7
- if (!response.ok) {
8
- throw new Error('Network response was not ok');
9
- }
10
- const markdown = await response.text();
11
- await navigator.clipboard.writeText(markdown);
12
- console.log('Markdown copied to clipboard');
13
- } catch (error) {
14
- console.error('There has been a problem with your fetch operation:', error);
15
- }
16
- };
17
-
18
- export function onSelectAIOption(value: string, makeMarkdownLink: boolean = true) {
19
- if (value === 'copy-markdown') {
20
- copyCurrentPageAsMarkdown();
21
- }
22
- if (value === 'view-as-markdown') {
23
- const currentUrl = new URL(window.location.href);
24
- const markdownUrl = `${currentUrl.origin}${currentUrl.pathname}.md`;
25
- window.open(markdownUrl, '_blank');
26
- }
27
-
28
- if (value === 'chat-gpt') {
29
- const currentUrl = new URL(window.location.href);
30
- const llmUrl = makeMarkdownLink ? `${currentUrl.origin}${currentUrl.pathname}.md` : currentUrl.href;
31
-
32
- const prompt = `Read from ${llmUrl} so I can ask questions about it.`;
33
-
34
- const chatGptUrl = `https://chatgpt.com/?hints=search&prompt=${encodeURIComponent(prompt)}`;
35
- window.open(chatGptUrl, '_blank');
36
- }
37
-
38
- if (value === 'claude') {
39
- const currentUrl = new URL(window.location.href);
40
- const llmUrl = makeMarkdownLink ? `${currentUrl.origin}${currentUrl.pathname}.md` : currentUrl.href;
41
-
42
- const prompt = `Read from ${llmUrl} so I can ask questions about it.`;
43
-
44
- const claudeUrl = `https://claude.ai/new?q=${encodeURIComponent(prompt)}`;
45
- window.open(claudeUrl, '_blank');
46
- }
47
-
48
- if (value === 'cursor') {
49
- const currentUrl = new URL(window.location.href);
50
- const llmUrl = makeMarkdownLink ? `${currentUrl.origin}${currentUrl.pathname}.md` : currentUrl.href;
51
-
52
- const prompt = `Read from ${llmUrl} so I can ask questions about it.`;
53
-
54
- const cursorUrl = `https://www.cursor.so/?prompt=${encodeURIComponent(prompt)}`;
55
- window.open(cursorUrl, '_blank');
56
- }
57
- }
@@ -1,86 +0,0 @@
1
- import {
2
- DropdownButton,
3
- DropdownButtonDivider,
4
- DropdownButtonItem,
5
- DropdownButtonItemIcon,
6
- DropdownButtonItemText,
7
- DropdownButtonItemTextSubtle,
8
- DropdownButtonMenu,
9
- DropdownButtonPrimaryAction,
10
- DropdownButtonPrimaryActionText,
11
- DropdownButtonTrigger,
12
- } from '@stainless-api/ui-primitives';
13
- import { CopyIcon } from 'lucide-react';
14
-
15
- export function AIDropdownOptions() {
16
- return (
17
- <>
18
- <DropdownButtonItem value="chat-gpt" isExternalLink>
19
- <DropdownButtonItemIcon>
20
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
21
- <path
22
- d="M3.13924 10.6036L6.28658 8.84444L6.33924 8.69111L6.28658 8.60638H6.13266L5.60608 8.5741L3.8076 8.52568L2.2481 8.46113L0.737215 8.38043L0.356456 8.29973L0 7.83169L0.0364557 7.59766L0.356456 7.38382L0.814177 7.42416L1.82684 7.49276L3.34582 7.59766L4.4476 7.66222L6.08 7.83169H6.33924L6.3757 7.72678L6.28658 7.66222L6.21772 7.59766L4.64608 6.53649L2.94481 5.4148L2.05367 4.76922L1.57165 4.44239L1.32861 4.13574L1.22329 3.46595L1.66076 2.98581L2.2481 3.02615L2.39797 3.0665L2.99342 3.52244L4.26532 4.50292L5.92608 5.72145L6.16911 5.92319L6.26633 5.8546L6.27848 5.80618L6.16911 5.62461L5.26582 3.99856L4.30177 2.34426L3.87241 1.65833L3.75899 1.24678C3.71848 1.07731 3.69013 0.93609 3.69013 0.762591L4.18835 0.0887672L4.4638 0L5.1281 0.0887672L5.4076 0.330859L5.82076 1.27098L6.48911 2.75178L7.52608 4.76518L7.82987 5.36234L7.9919 5.91512L8.05266 6.08459H8.15797V5.98775L8.24304 4.85395L8.40101 3.46192L8.55494 1.67044L8.60759 1.16608L8.85873 0.560847L9.35696 0.234023L9.74582 0.419627L10.0658 0.875567L10.0213 1.17011L9.83089 2.40075L9.45823 4.32942L9.21519 5.62058H9.35696L9.51899 5.45918L10.1752 4.59168L11.277 3.21983L11.763 2.67512L12.3301 2.07392L12.6947 1.78745H13.3833L13.8896 2.53793L13.6628 3.31263L12.9539 4.20837L12.3666 4.96693L11.5241 6.09669L10.9975 7.0005L11.0461 7.07313L11.1716 7.06103L13.0754 6.65754L14.1043 6.47193L15.3316 6.26212L15.8866 6.52035L15.9473 6.78262L15.7286 7.31926L14.4162 7.64205L12.877 7.9487L10.5843 8.48937L10.5559 8.50954L10.5884 8.54989L11.6213 8.64673L12.0628 8.67094H13.1443L15.1575 8.82023L15.6841 9.16723L16 9.59089L15.9473 9.91368L15.1372 10.3252L14.0435 10.067L11.4916 9.46177L10.6167 9.24389H10.4952V9.31652L11.2243 10.0267L12.561 11.229L14.2339 12.7784L14.319 13.1618L14.1043 13.4644L13.8775 13.4321L12.4071 12.3306L11.84 11.8343L10.5559 10.757H10.4709V10.8699L10.7666 11.3017L12.3301 13.6419L12.4111 14.3601L12.2977 14.5941L11.8927 14.7354L11.4471 14.6547L10.5316 13.3756L9.58785 11.9352L8.82633 10.644L8.73316 10.6964L8.28354 15.5181L8.07291 15.7642L7.58684 15.9498L7.18177 15.6432L6.96709 15.1469L7.18177 14.1664L7.44101 12.8874L7.65165 11.8706L7.84203 10.6077L7.95544 10.1881L7.94734 10.1598L7.85418 10.1719L6.89823 11.4792L5.44405 13.4361L4.29367 14.6627L4.01823 14.7717L3.54025 14.5255L3.58481 14.0857L3.85215 13.6944L5.44405 11.6769L6.40405 10.4261L7.0238 9.70387L7.01975 9.59896H6.98329L2.75443 12.3346L2.00101 12.4314L1.67696 12.1288L1.71747 11.6325L1.87139 11.4711L3.14329 10.5996L3.13924 10.6036Z"
23
- fill="#D97757"
24
- />
25
- </svg>
26
- </DropdownButtonItemIcon>
27
- <DropdownButtonItemText>
28
- <DropdownButtonItemTextSubtle>Open in</DropdownButtonItemTextSubtle> Claude
29
- </DropdownButtonItemText>
30
- </DropdownButtonItem>
31
- <DropdownButtonItem value="chat-gpt" isExternalLink>
32
- <DropdownButtonItemIcon>
33
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
34
- <g clip-path="url(#clip0_2771_126147)">
35
- <path
36
- d="M14.853 6.54857C15.216 5.45907 15.091 4.26557 14.5105 3.27457C13.6375 1.75457 11.8825 0.972574 10.1685 1.34057C9.40596 0.481574 8.31046 -0.00692579 7.16196 7.42116e-05C5.40996 -0.00392579 3.85546 1.12407 3.31646 2.79107C2.19096 3.02157 1.21946 3.72607 0.650955 4.72457C-0.228545 6.24057 -0.0280446 8.15157 1.14696 9.45157C0.783955 10.5411 0.908955 11.7346 1.48946 12.7256C2.36246 14.2456 4.11746 15.0276 5.83146 14.6596C6.59346 15.5186 7.68946 16.0071 8.83796 15.9996C10.591 16.0041 12.146 14.8751 12.685 13.2066C13.8105 12.9761 14.782 12.2716 15.3505 11.2731C16.229 9.75707 16.028 7.84757 14.8535 6.54757L14.853 6.54857ZM8.83896 14.9541C8.13746 14.9551 7.45796 14.7096 6.91946 14.2601C6.94396 14.2471 6.98646 14.2236 7.01396 14.2066L10.2 12.3666C10.363 12.2741 10.463 12.1006 10.462 11.9131V7.42157L11.8085 8.19907C11.823 8.20607 11.8325 8.22007 11.8345 8.23607V11.9556C11.8325 13.6096 10.493 14.9506 8.83896 14.9541ZM2.39696 12.2026C2.04546 11.5956 1.91896 10.8841 2.03946 10.1936C2.06296 10.2076 2.10446 10.2331 2.13396 10.2501L5.31996 12.0901C5.48146 12.1846 5.68146 12.1846 5.84346 12.0901L9.73296 9.84407V11.3991C9.73396 11.4151 9.72646 11.4306 9.71396 11.4406L6.49346 13.3001C5.05896 14.1261 3.22696 13.6351 2.39746 12.2026H2.39696ZM1.55846 5.24807C1.90846 4.64007 2.46096 4.17507 3.11896 3.93357C3.11896 3.96107 3.11746 4.00957 3.11746 4.04357V7.72407C3.11646 7.91107 3.21646 8.08457 3.37896 8.17707L7.26846 10.4226L5.92196 11.2001C5.90846 11.2091 5.89146 11.2106 5.87646 11.2041L2.65546 9.34307C1.22396 8.51407 0.732955 6.68257 1.55796 5.24857L1.55846 5.24807ZM12.6215 7.82257L8.73196 5.57657L10.0785 4.79957C10.092 4.79057 10.109 4.78907 10.124 4.79557L13.345 6.65507C14.779 7.48357 15.2705 9.31807 14.442 10.7521C14.0915 11.3591 13.5395 11.8241 12.882 12.0661V8.27557C12.8835 8.08857 12.784 7.91557 12.622 7.82257H12.6215ZM13.9615 5.80557C13.938 5.79107 13.8965 5.76607 13.867 5.74907L10.681 3.90907C10.5195 3.81457 10.3195 3.81457 10.1575 3.90907L6.26796 6.15507V4.60007C6.26696 4.58407 6.27446 4.56857 6.28696 4.55857L9.50746 2.70057C10.942 1.87307 12.776 2.36557 13.603 3.80057C13.9525 4.40657 14.079 5.11607 13.9605 5.80557H13.9615ZM5.53596 8.57707L4.18896 7.79957C4.17446 7.79257 4.16496 7.77857 4.16296 7.76257V4.04307C4.16396 2.38707 5.50746 1.04507 7.16346 1.04607C7.86396 1.04607 8.54196 1.29207 9.08046 1.74007C9.05596 1.75307 9.01396 1.77657 8.98596 1.79357L5.79996 3.63357C5.63696 3.72607 5.53696 3.89907 5.53796 4.08657L5.53596 8.57607V8.57707ZM6.26746 7.00007L7.99996 5.99957L9.73246 6.99957V9.00007L7.99996 10.0001L6.26746 9.00007V7.00007Z"
37
- fill="#262626"
38
- />
39
- </g>
40
- <defs>
41
- <clipPath id="clip0_2771_126147">
42
- <rect width="16" height="16" fill="white" />
43
- </clipPath>
44
- </defs>
45
- </svg>
46
- </DropdownButtonItemIcon>
47
- <DropdownButtonItemText>
48
- <DropdownButtonItemTextSubtle>Open in</DropdownButtonItemTextSubtle> ChatGPT
49
- </DropdownButtonItemText>
50
- </DropdownButtonItem>
51
- </>
52
- );
53
- }
54
-
55
- export function APIReferenceAIDropdown() {
56
- return (
57
- <DropdownButton id="ai-dropdown-button">
58
- <DropdownButtonPrimaryAction>
59
- <CopyIcon size={16} />
60
- <DropdownButtonPrimaryActionText>Copy Markdown</DropdownButtonPrimaryActionText>
61
- </DropdownButtonPrimaryAction>
62
- <DropdownButtonTrigger />
63
- <DropdownButtonMenu>
64
- <AIDropdownOptions />
65
- <DropdownButtonDivider />
66
- <DropdownButtonItem value="copy-as-markdown" isExternalLink>
67
- <DropdownButtonItemIcon>
68
- <CopyIcon size={16} />
69
- </DropdownButtonItemIcon>
70
- <DropdownButtonItemText>Copy Markdown</DropdownButtonItemText>
71
- </DropdownButtonItem>
72
- <DropdownButtonItem value="view-as-markdown" isExternalLink>
73
- <DropdownButtonItemIcon>
74
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
75
- <path
76
- d="M14.8447 3.33301C15.151 3.33301 15.4455 3.45527 15.6621 3.67188C15.8785 3.88844 16 4.18213 16 4.48828V12.0254C15.9997 12.3315 15.8777 12.6254 15.6611 12.8418C15.4446 13.0581 15.1508 13.1797 14.8447 13.1797H1.15527C0.848967 13.1797 0.55449 13.0584 0.337891 12.8418C0.121288 12.6252 0 12.3307 0 12.0244V4.48828C1.09706e-05 4.18213 0.121501 3.88844 0.337891 3.67188C0.554493 3.45527 0.848951 3.33301 1.15527 3.33301H14.8447ZM1.15527 4.10254C1.10457 4.10245 1.0537 4.11247 1.00684 4.13184C0.960202 4.15116 0.917554 4.17917 0.881836 4.21484C0.845984 4.2507 0.817213 4.29396 0.797852 4.34082C0.778601 4.38756 0.769447 4.43773 0.769531 4.48828V12.0254C0.76962 12.0759 0.779409 12.1262 0.798828 12.1729C0.81827 12.2196 0.846978 12.2621 0.882812 12.2979C0.918602 12.3335 0.961134 12.3616 1.00781 12.3809C1.05454 12.4001 1.10474 12.4102 1.15527 12.4102H14.8447C14.9467 12.4101 15.045 12.3699 15.1172 12.2979C15.1893 12.2258 15.2293 12.1274 15.2295 12.0254V4.48828C15.2296 4.43774 15.2204 4.38755 15.2012 4.34082C15.1819 4.29403 15.1529 4.25166 15.1172 4.21582C15.0814 4.17999 15.0389 4.15126 14.9922 4.13184C14.9455 4.11249 14.8952 4.10258 14.8447 4.10254H1.15527ZM5.38477 7.56348L6.92285 5.64062H8.46094V10.8721H6.92285V7.87109L5.38477 9.79492L3.8457 7.87109V10.8711H2.30762V5.63965H3.8457L5.38477 7.56348ZM12.6924 8.33301H14.2305L11.9229 10.8711L9.61523 8.33301H11.1533V5.64062H12.6924V8.33301Z"
77
- fill="#262626"
78
- />
79
- </svg>
80
- </DropdownButtonItemIcon>
81
- <DropdownButtonItemText>View as Markdown</DropdownButtonItemText>
82
- </DropdownButtonItem>
83
- </DropdownButtonMenu>
84
- </DropdownButton>
85
- );
86
- }
@@ -1,64 +0,0 @@
1
- import {
2
- DropdownButton,
3
- DropdownButtonMenu,
4
- DropdownButtonPrimaryAction,
5
- DropdownButtonTrigger,
6
- } from '@stainless-api/ui-primitives';
7
- import { AIDropdownOptions } from '../APIReferenceAIDropdown';
8
- import type { StarlightRouteData } from '@astrojs/starlight/route-data';
9
-
10
- const sidebarHasEntry = (sidebarEntry: StarlightRouteData['sidebar'], currentPath?: string) => {
11
- if (!currentPath) return false;
12
- const normalizePath = (path: string) => {
13
- return path.endsWith('/') ? path : path + '/';
14
- };
15
-
16
- const normalizedCurrent = normalizePath(currentPath);
17
-
18
- for (const entry of sidebarEntry) {
19
- if (entry.type === 'link') {
20
- const normalizedHref = normalizePath(entry.href);
21
- if (normalizedHref === normalizedCurrent) {
22
- return true;
23
- }
24
- } else if (entry.type === 'group') {
25
- const hasInGroup = sidebarHasEntry(entry.entries, currentPath);
26
- if (hasInGroup) return true;
27
- }
28
- }
29
-
30
- return false;
31
- };
32
-
33
- export function ProseAIDropdown({
34
- currentPath,
35
- sidebarEntry,
36
- }: {
37
- currentPath: string;
38
- sidebarEntry: StarlightRouteData['sidebar'];
39
- }) {
40
- // Hide if there is no associated sidebar entry. This applies to pages like the 404 page.
41
- const hasEntry = sidebarHasEntry(sidebarEntry, currentPath);
42
-
43
- if (!hasEntry) {
44
- return null;
45
- }
46
-
47
- return (
48
- <DropdownButton id="prose-ai-dropdown-button">
49
- <DropdownButtonPrimaryAction>
50
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
51
- <path
52
- d="M3.13924 10.6036L6.28658 8.84444L6.33924 8.69111L6.28658 8.60638H6.13266L5.60608 8.5741L3.8076 8.52568L2.2481 8.46113L0.737215 8.38043L0.356456 8.29973L0 7.83169L0.0364557 7.59766L0.356456 7.38382L0.814177 7.42416L1.82684 7.49276L3.34582 7.59766L4.4476 7.66222L6.08 7.83169H6.33924L6.3757 7.72678L6.28658 7.66222L6.21772 7.59766L4.64608 6.53649L2.94481 5.4148L2.05367 4.76922L1.57165 4.44239L1.32861 4.13574L1.22329 3.46595L1.66076 2.98581L2.2481 3.02615L2.39797 3.0665L2.99342 3.52244L4.26532 4.50292L5.92608 5.72145L6.16911 5.92319L6.26633 5.8546L6.27848 5.80618L6.16911 5.62461L5.26582 3.99856L4.30177 2.34426L3.87241 1.65833L3.75899 1.24678C3.71848 1.07731 3.69013 0.93609 3.69013 0.762591L4.18835 0.0887672L4.4638 0L5.1281 0.0887672L5.4076 0.330859L5.82076 1.27098L6.48911 2.75178L7.52608 4.76518L7.82987 5.36234L7.9919 5.91512L8.05266 6.08459H8.15797V5.98775L8.24304 4.85395L8.40101 3.46192L8.55494 1.67044L8.60759 1.16608L8.85873 0.560847L9.35696 0.234023L9.74582 0.419627L10.0658 0.875567L10.0213 1.17011L9.83089 2.40075L9.45823 4.32942L9.21519 5.62058H9.35696L9.51899 5.45918L10.1752 4.59168L11.277 3.21983L11.763 2.67512L12.3301 2.07392L12.6947 1.78745H13.3833L13.8896 2.53793L13.6628 3.31263L12.9539 4.20837L12.3666 4.96693L11.5241 6.09669L10.9975 7.0005L11.0461 7.07313L11.1716 7.06103L13.0754 6.65754L14.1043 6.47193L15.3316 6.26212L15.8866 6.52035L15.9473 6.78262L15.7286 7.31926L14.4162 7.64205L12.877 7.9487L10.5843 8.48937L10.5559 8.50954L10.5884 8.54989L11.6213 8.64673L12.0628 8.67094H13.1443L15.1575 8.82023L15.6841 9.16723L16 9.59089L15.9473 9.91368L15.1372 10.3252L14.0435 10.067L11.4916 9.46177L10.6167 9.24389H10.4952V9.31652L11.2243 10.0267L12.561 11.229L14.2339 12.7784L14.319 13.1618L14.1043 13.4644L13.8775 13.4321L12.4071 12.3306L11.84 11.8343L10.5559 10.757H10.4709V10.8699L10.7666 11.3017L12.3301 13.6419L12.4111 14.3601L12.2977 14.5941L11.8927 14.7354L11.4471 14.6547L10.5316 13.3756L9.58785 11.9352L8.82633 10.644L8.73316 10.6964L8.28354 15.5181L8.07291 15.7642L7.58684 15.9498L7.18177 15.6432L6.96709 15.1469L7.18177 14.1664L7.44101 12.8874L7.65165 11.8706L7.84203 10.6077L7.95544 10.1881L7.94734 10.1598L7.85418 10.1719L6.89823 11.4792L5.44405 13.4361L4.29367 14.6627L4.01823 14.7717L3.54025 14.5255L3.58481 14.0857L3.85215 13.6944L5.44405 11.6769L6.40405 10.4261L7.0238 9.70387L7.01975 9.59896H6.98329L2.75443 12.3346L2.00101 12.4314L1.67696 12.1288L1.71747 11.6325L1.87139 11.4711L3.14329 10.5996L3.13924 10.6036Z"
53
- fill="#D97757"
54
- />
55
- </svg>{' '}
56
- Open in Claude
57
- </DropdownButtonPrimaryAction>
58
- <DropdownButtonTrigger />
59
- <DropdownButtonMenu>
60
- <AIDropdownOptions />
61
- </DropdownButtonMenu>
62
- </DropdownButton>
63
- );
64
- }