@stainless-api/docs 0.1.0-beta.0

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 (119) hide show
  1. package/.env.example +1 -0
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +11 -0
  4. package/components/variables.css +139 -0
  5. package/eslint.config.js +10 -0
  6. package/package.json +74 -0
  7. package/plugin/assets/fonts/geist/OFL.txt +93 -0
  8. package/plugin/assets/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
  9. package/plugin/assets/fonts/geist/geist-italic-latin.woff2 +0 -0
  10. package/plugin/assets/fonts/geist/geist-latin-ext.woff2 +0 -0
  11. package/plugin/assets/fonts/geist/geist-latin.woff2 +0 -0
  12. package/plugin/assets/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
  13. package/plugin/assets/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
  14. package/plugin/assets/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
  15. package/plugin/assets/fonts/geist/geist-mono-latin.woff2 +0 -0
  16. package/plugin/assets/languages/curl.svg +10 -0
  17. package/plugin/assets/languages/go.svg +4 -0
  18. package/plugin/assets/languages/java.svg +7 -0
  19. package/plugin/assets/languages/kotlin.svg +10 -0
  20. package/plugin/assets/languages/powershell.svg +3 -0
  21. package/plugin/assets/languages/python.svg +19 -0
  22. package/plugin/assets/languages/ruby.svg +125 -0
  23. package/plugin/assets/languages/terraform.svg +5 -0
  24. package/plugin/assets/languages/typescript.svg +11 -0
  25. package/plugin/assets/stainless-logo-dark.png +0 -0
  26. package/plugin/assets/stainless-logo.png +0 -0
  27. package/plugin/buildAlgoliaIndex.ts +72 -0
  28. package/plugin/cms/client.ts +62 -0
  29. package/plugin/cms/server.ts +268 -0
  30. package/plugin/cms/sidebar-builder.ts +420 -0
  31. package/plugin/cms/worker.ts +122 -0
  32. package/plugin/components/SDKSelect.astro +154 -0
  33. package/plugin/components/SnippetCode.tsx +212 -0
  34. package/plugin/components/search/Search.astro +6 -0
  35. package/plugin/components/search/SearchAlgolia.astro +87 -0
  36. package/plugin/components/search/SearchIsland.tsx +100 -0
  37. package/plugin/generateAPIReferenceLink.ts +71 -0
  38. package/plugin/globalJs/ai-dropdown.ts +57 -0
  39. package/plugin/globalJs/code-snippets.ts +87 -0
  40. package/plugin/globalJs/copy.ts +37 -0
  41. package/plugin/globalJs/navigation.ts +81 -0
  42. package/plugin/globalJs/tooltip.ts +32 -0
  43. package/plugin/helpers/getPageLoadEvent.ts +8 -0
  44. package/plugin/index.ts +308 -0
  45. package/plugin/languages.ts +67 -0
  46. package/plugin/loadPluginConfig.ts +273 -0
  47. package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +5 -0
  48. package/plugin/middlewareBuilder/stlStarlightMiddleware.ts +5 -0
  49. package/plugin/react/Routing.tsx +435 -0
  50. package/plugin/referencePlaceholderUtils.ts +82 -0
  51. package/plugin/replaceSidebarPlaceholderMiddleware.ts +50 -0
  52. package/plugin/routes/Docs.astro +171 -0
  53. package/plugin/routes/DocsStatic.astro +14 -0
  54. package/plugin/routes/Overview.astro +67 -0
  55. package/plugin/routes/markdown.ts +58 -0
  56. package/plugin/vendor/preview.worker.docs.js +21657 -0
  57. package/plugin/vendor/templates/go.md +314 -0
  58. package/plugin/vendor/templates/java.md +87 -0
  59. package/plugin/vendor/templates/kotlin.md +87 -0
  60. package/plugin/vendor/templates/node.md +233 -0
  61. package/plugin/vendor/templates/python.md +249 -0
  62. package/plugin/vendor/templates/ruby.md +145 -0
  63. package/plugin/vendor/templates/terraform.md +60 -0
  64. package/plugin/vendor/templates/typescript.md +317 -0
  65. package/scripts/vendor_deps.ts +50 -0
  66. package/shared/virtualModule.ts +7 -0
  67. package/stl-docs/components/APIReferenceAIDropdown.tsx +86 -0
  68. package/stl-docs/components/ClientRouterHead.astro +41 -0
  69. package/stl-docs/components/Header.astro +91 -0
  70. package/stl-docs/components/Sidebar.astro +11 -0
  71. package/stl-docs/components/ThemeSelect.astro +225 -0
  72. package/stl-docs/components/content-panel/ContentBreadcrumbs.tsx +84 -0
  73. package/stl-docs/components/content-panel/ContentPanel.astro +72 -0
  74. package/stl-docs/components/content-panel/ProseAIDropdown.tsx +64 -0
  75. package/stl-docs/components/headers/DefaultHeader.astro +36 -0
  76. package/stl-docs/components/headers/HeaderLinks.astro +16 -0
  77. package/stl-docs/components/headers/SplashMobileMenuToggle.astro +49 -0
  78. package/stl-docs/components/headers/StackedHeader.astro +75 -0
  79. package/stl-docs/components/mintlify-compat/Accordion.astro +46 -0
  80. package/stl-docs/components/mintlify-compat/AccordionGroup.astro +25 -0
  81. package/stl-docs/components/mintlify-compat/Card.tsx +32 -0
  82. package/stl-docs/components/mintlify-compat/Columns.astro +66 -0
  83. package/stl-docs/components/mintlify-compat/Frame.astro +37 -0
  84. package/stl-docs/components/mintlify-compat/Step.astro +58 -0
  85. package/stl-docs/components/mintlify-compat/Steps.astro +17 -0
  86. package/stl-docs/components/mintlify-compat/Tab.astro +13 -0
  87. package/stl-docs/components/mintlify-compat/Tabs.astro +7 -0
  88. package/stl-docs/components/mintlify-compat/callouts/Callout.astro +7 -0
  89. package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -0
  90. package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -0
  91. package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -0
  92. package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -0
  93. package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -0
  94. package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -0
  95. package/stl-docs/components/mintlify-compat/callouts/index.ts +9 -0
  96. package/stl-docs/components/mintlify-compat/card.css +44 -0
  97. package/stl-docs/components/mintlify-compat/index.ts +15 -0
  98. package/stl-docs/components/nav-tabs/NavDropdown.astro +106 -0
  99. package/stl-docs/components/nav-tabs/NavTabs.astro +165 -0
  100. package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +62 -0
  101. package/stl-docs/components/nav-tabs/buildNavLinks.ts +14 -0
  102. package/stl-docs/index.ts +174 -0
  103. package/stl-docs/loadStlDocsConfig.ts +160 -0
  104. package/stl-docs/redirects.ts +33 -0
  105. package/stl-docs/tabsMiddleware.ts +183 -0
  106. package/styles/code.css +189 -0
  107. package/styles/fonts.css +68 -0
  108. package/styles/links.css +51 -0
  109. package/styles/mintlify-compat.css +1 -0
  110. package/styles/overrides.css +79 -0
  111. package/styles/page.css +76 -0
  112. package/styles/sdk_select.css +11 -0
  113. package/styles/search.css +85 -0
  114. package/styles/sidebar.css +168 -0
  115. package/styles/toc.css +42 -0
  116. package/styles/variables.css +18 -0
  117. package/theme.css +15 -0
  118. package/tsconfig.json +18 -0
  119. package/virtual-module.d.ts +43 -0
@@ -0,0 +1,225 @@
1
+ ---
2
+ import {
3
+ Dropdown,
4
+ DropdownTrigger,
5
+ DropdownMenu,
6
+ DropdownItem,
7
+ } from '@stainless-api/docs-ui/src/components/dropdown';
8
+
9
+ const options = [
10
+ {
11
+ value: 'auto',
12
+ label: 'Auto',
13
+ icon: `<svg
14
+ width="24"
15
+ height="24"
16
+ viewBox="0 0 24 24"
17
+ fill="none"
18
+ xmlns="http://www.w3.org/2000/svg"
19
+ >
20
+ <path
21
+ d="M21 5C21 4.44771 20.5523 4 20 4H4C3.44772 4 3 4.44772 3 5V15C3 15.5523 3.44772 16 4 16H20C20.5523 16 21 15.5523 21 15V5ZM23 15C23 16.6569 21.6569 18 20 18H13V20H16C16.5523 20 17 20.4477 17 21C17 21.5523 16.5523 22 16 22H8C7.44772 22 7 21.5523 7 21C7 20.4477 7.44772 20 8 20H11V18H4C2.34315 18 1 16.6569 1 15V5C1 3.34315 2.34315 2 4 2H20C21.6569 2 23 3.34315 23 5V15Z"
22
+ fill="#262626"></path></svg
23
+ >`,
24
+ },
25
+ {
26
+ value: 'light',
27
+ label: 'Light',
28
+ icon: `<svg
29
+ width="24"
30
+ height="24"
31
+ viewBox="0 0 24 24"
32
+ fill="none"
33
+ xmlns="http://www.w3.org/2000/svg"
34
+ >
35
+ <path
36
+ d="M11 22V20C11 19.4477 11.4477 19 12 19C12.5523 19 13 19.4477 13 20V22C13 22.5523 12.5523 23 12 23C11.4477 23 11 22.5523 11 22ZM5.63281 16.9531C6.02332 16.5626 6.65635 16.5626 7.04688 16.9531C7.4374 17.3436 7.4374 17.9767 7.04688 18.3672L5.6377 19.7773C5.24717 20.1679 4.61318 20.1679 4.22266 19.7773C3.83232 19.387 3.83259 18.7538 4.22266 18.3633L5.63281 16.9531ZM16.9531 16.9531C17.3191 16.5871 17.8982 16.5637 18.291 16.8838L18.3672 16.9531L19.7773 18.3633L19.8457 18.4385C20.1663 18.8313 20.1435 19.4111 19.7773 19.7773C19.4113 20.1433 18.8322 20.1658 18.4395 19.8457L18.3633 19.7773L16.9531 18.3672L16.8848 18.291C16.5643 17.8983 16.5871 17.3193 16.9531 16.9531ZM15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12ZM4 11C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12C1 11.4477 1.44772 11 2 11H4ZM22 11C22.5523 11 23 11.4477 23 12C23 12.5523 22.5523 13 22 13H20C19.4477 13 19 12.5523 19 12C19 11.4477 19.4477 11 20 11H22ZM7.04688 5.63281C7.4374 6.02334 7.4374 6.65635 7.04688 7.04688C6.65634 7.43728 6.0233 7.43736 5.63281 7.04688L4.22266 5.63672L5.6377 4.22266L7.04688 5.63281ZM18.3633 4.22266C18.7538 3.83235 19.3869 3.83224 19.7773 4.22266C20.1678 4.61311 20.1677 5.24618 19.7773 5.63672L18.3672 7.04688C17.9767 7.4374 17.3436 7.4374 16.9531 7.04688C16.5626 6.65635 16.5626 6.02332 16.9531 5.63281L18.3633 4.22266ZM4.22266 4.22266C4.61318 3.83213 5.24717 3.83213 5.6377 4.22266L4.22266 5.63672C3.83254 5.24621 3.83238 4.61307 4.22266 4.22266ZM11 4V2C11 1.44772 11.4477 1 12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4ZM17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12Z"
37
+ fill="#262626"></path></svg
38
+ >`,
39
+ },
40
+ {
41
+ value: 'dark',
42
+ label: 'Dark',
43
+ icon: `<svg
44
+ width="24"
45
+ height="24"
46
+ viewBox="0 0 24 24"
47
+ fill="none"
48
+ xmlns="http://www.w3.org/2000/svg"
49
+ >
50
+ <path
51
+ d="M9.13569 7.5C9.13569 6.37669 9.39314 5.28007 9.87397 4.28809C9.05381 4.51419 8.27063 4.87087 7.55561 5.34863C6.24009 6.22764 5.21483 7.47676 4.60932 8.93848C4.00386 10.4002 3.84465 12.0088 4.15327 13.5605C4.46195 15.1124 5.2239 16.5384 6.34272 17.6572C7.46154 18.776 8.88756 19.538 10.4394 19.8467C11.9912 20.1553 13.5997 19.9961 15.0615 19.3906C16.5232 18.7851 17.7723 17.7599 18.6513 16.4443C19.1292 15.7291 19.4848 14.9454 19.7109 14.125C18.719 14.6057 17.6231 14.8643 16.4999 14.8643C14.5469 14.8643 12.6739 14.088 11.2929 12.707C9.91191 11.326 9.13569 9.45304 9.13569 7.5ZM11.1357 7.5C11.1357 8.92261 11.701 10.287 12.707 11.293C13.7129 12.2989 15.0773 12.8643 16.4999 12.8643C17.9226 12.8643 19.287 12.2989 20.2929 11.293C20.5789 11.007 21.0091 10.9214 21.3828 11.0762C21.7564 11.231 22 11.5956 22 12C22 13.9778 21.4132 15.9112 20.3144 17.5557C19.2156 19.2001 17.6543 20.4824 15.8271 21.2393C13.9998 21.9961 11.9886 22.1935 10.0488 21.8076C8.10909 21.4217 6.32711 20.4697 4.92866 19.0713C3.53021 17.6728 2.57822 15.8909 2.19233 13.9512C1.80648 12.0114 2.00382 10.0001 2.76069 8.17285C3.51756 6.34567 4.79987 4.78434 6.44429 3.68555C8.08878 2.58673 10.0221 2 11.9999 2C12.4044 2 12.769 2.24359 12.9238 2.61719C13.0786 2.99086 12.993 3.42103 12.707 3.70703C11.701 4.71297 11.1357 6.07739 11.1357 7.5Z"
52
+ fill="#262626"></path></svg
53
+ >`,
54
+ },
55
+ ];
56
+ ---
57
+
58
+ <div class="stldocs-root theme-select-root">
59
+ <Dropdown className="theme-select-container" data-theme-select>
60
+ <DropdownTrigger withChevron>
61
+ <span class="stl-dropdown-icon">
62
+ {options.map(({ value, label, icon }) => <Fragment set:html={icon} />)}
63
+ </span>
64
+ </DropdownTrigger>
65
+ <DropdownMenu role="listbox">
66
+ {
67
+ options.map(({ value, label, icon }) => (
68
+ <DropdownItem role="option" value={value}>
69
+ <div>
70
+ <span class="stl-dropdown-icon">
71
+ <Fragment set:html={icon} />
72
+ </span>
73
+ <span class="stl-dropdown-label">{label}</span>
74
+ </div>
75
+ </DropdownItem>
76
+ ))
77
+ }
78
+ </DropdownMenu>
79
+ </Dropdown>
80
+ </div>
81
+
82
+ {/* Inlined to avoid FOUC. Uses global scope from `ThemeProvider.astro` */}
83
+ <script is:inline>
84
+ document.addEventListener('astro:page-load', () => {
85
+ StarlightThemeProvider.updatePickers();
86
+ });
87
+ StarlightThemeProvider.updatePickers();
88
+ </script>
89
+
90
+ <script>
91
+ import { getPageLoadEvent } from '../../plugin/helpers/getPageLoadEvent';
92
+
93
+ const storageKey = 'starlight-theme';
94
+
95
+ type Theme = 'auto' | 'dark' | 'light';
96
+
97
+ const parseTheme = (val: unknown): Theme =>
98
+ val === 'auto' || val === 'dark' || val === 'light' ? val : 'auto';
99
+
100
+ const loadTheme = (): Theme => parseTheme(localStorage.getItem(storageKey));
101
+
102
+ const storeTheme = (theme: Theme) => {
103
+ localStorage.setItem(storageKey, theme === 'light' || theme === 'dark' ? theme : '');
104
+ };
105
+
106
+ const getPreferredColorScheme = (): Theme =>
107
+ window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
108
+
109
+ const highlightSelected = (doc: Document, theme: Theme) => {
110
+ doc.querySelectorAll('.theme-select-container.stldocs-dropdown').forEach((container) => {
111
+ const icons = container.querySelectorAll('.stl-dropdown-icon svg');
112
+ icons.forEach((icon, index) => {
113
+ const themeForIcon = ['auto', 'light', 'dark'][index];
114
+ icon.classList.toggle('selected', theme === themeForIcon);
115
+ });
116
+
117
+ container.querySelectorAll('.stldocs-dropdown-item').forEach((option) => {
118
+ const label = option.querySelector('.stl-dropdown-label')?.textContent?.toLowerCase();
119
+ option.classList.toggle('selected', label === theme);
120
+ });
121
+
122
+ const menu = container.querySelector('.stldocs-dropdown-menu');
123
+ menu?.classList.remove('open');
124
+ });
125
+ };
126
+
127
+ const applyTheme = (doc: Document, theme: Theme) => {
128
+ const effective = theme === 'auto' ? getPreferredColorScheme() : theme;
129
+ doc.documentElement.dataset.theme = effective;
130
+ storeTheme(theme);
131
+ StarlightThemeProvider?.updatePickers?.(theme);
132
+ highlightSelected(doc, theme);
133
+ };
134
+
135
+ function setupThemeMode(doc: Document) {
136
+ // Attach to all instances of .theme-select-container.stldocs-dropdown. We need this because
137
+ // the theme component is used in the mobile dropdown and the desktop sidebar.
138
+ doc.querySelectorAll('.theme-select-container.stldocs-dropdown').forEach((container) => {
139
+ const trigger = container.querySelector('.stldocs-dropdown-trigger');
140
+ const menu = container.querySelector('.stldocs-dropdown-menu');
141
+
142
+ if (trigger && menu) {
143
+ trigger.addEventListener('click', (e) => {
144
+ e.stopPropagation();
145
+
146
+ doc.querySelectorAll('.theme-select-container .stldocs-dropdown-menu.open').forEach((otherMenu) => {
147
+ if (otherMenu !== menu) otherMenu.classList.remove('open');
148
+ });
149
+
150
+ menu.classList.toggle('open');
151
+ });
152
+
153
+ container.querySelectorAll('.stldocs-dropdown-item').forEach((option) => {
154
+ option.addEventListener('click', () => {
155
+ const label = option.querySelector('.stl-dropdown-label')?.textContent?.toLowerCase() ?? '';
156
+ if (['auto', 'light', 'dark'].includes(label)) {
157
+ applyTheme(doc, label as Theme);
158
+ }
159
+ });
160
+ });
161
+ }
162
+ });
163
+
164
+ // Close dropdown if you click outside
165
+ doc.addEventListener('click', (e) => {
166
+ doc.querySelectorAll('.theme-select-container .stldocs-dropdown-menu.open').forEach((menu) => {
167
+ if (e.target instanceof HTMLElement && !menu.contains(e.target)) {
168
+ menu.classList.remove('open');
169
+ }
170
+ });
171
+ });
172
+
173
+ // React to system preference changes
174
+ matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
175
+ if (loadTheme() === 'auto') applyTheme(doc, 'auto');
176
+ });
177
+
178
+ applyTheme(doc, loadTheme());
179
+ }
180
+
181
+ document.addEventListener('astro:before-swap', (event) => {
182
+ applyTheme(event.newDocument, loadTheme());
183
+ });
184
+
185
+ document.addEventListener(getPageLoadEvent(), (e) => {
186
+ setupThemeMode(document);
187
+ });
188
+ </script>
189
+
190
+ <style is:global>
191
+ .theme-select-root {
192
+ background-color: unset;
193
+ display: flex;
194
+ align-items: center;
195
+ }
196
+ .stl-dropdown-icon svg {
197
+ width: 16px;
198
+ height: 16px;
199
+
200
+ path {
201
+ fill: var(--sl-color-gray-2);
202
+ }
203
+ }
204
+
205
+ .stldocs-dropdown-trigger .stl-dropdown-icon svg {
206
+ display: none;
207
+
208
+ &.selected {
209
+ display: flex;
210
+ }
211
+ }
212
+ .stl-dropdown-icon {
213
+ display: flex;
214
+ align-items: center;
215
+ justify-content: center;
216
+ width: 16px;
217
+ height: 16px;
218
+ }
219
+
220
+ span.stl-dropdown-icon,
221
+ span.stl-dropdown-chevron {
222
+ padding-left: 0;
223
+ padding-right: 0%;
224
+ }
225
+ </style>
@@ -0,0 +1,84 @@
1
+ import { ChevronRight } from 'lucide-react';
2
+ import { Join } from '@stainless-api/docs-ui/src/components';
3
+ import style from '@stainless-api/docs-ui/src/style';
4
+ import type { StarlightRouteData } from '@astrojs/starlight/route-data';
5
+
6
+ type Breadcrumb = { title: string; href: string };
7
+
8
+ // Normalize paths to avoid mismatches due to trailing slashes
9
+ function normalizePath(path: string) {
10
+ return path.endsWith('/') ? path : path + '/';
11
+ }
12
+
13
+ export function findBreadcrumbTrail(
14
+ sidebarEntry: StarlightRouteData['sidebar'],
15
+ targetPath: string,
16
+ includeCurrentPage: boolean,
17
+ trail: Breadcrumb[] = [],
18
+ ): 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
+ const normalizedTarget = normalizePath(targetPath);
25
+
26
+ for (const entry of entries) {
27
+ if (entry.type === 'link') {
28
+ const normalizedHref = normalizePath(entry.href);
29
+ if (normalizedHref === normalizedTarget) {
30
+ const fullTrail = [...trail, { title: entry.label, href: entry.href }];
31
+ if (includeCurrentPage || fullTrail.length === 1) {
32
+ return fullTrail;
33
+ } else {
34
+ return fullTrail.slice(0, -1);
35
+ }
36
+ }
37
+ } else if (entry.type === 'group') {
38
+ const groupBreadcrumb: Breadcrumb = { title: entry.label, href: '' };
39
+ const result = findBreadcrumbTrail(entry.entries, targetPath, includeCurrentPage, [
40
+ ...trail,
41
+ groupBreadcrumb,
42
+ ]);
43
+ if (result) return result;
44
+ }
45
+ }
46
+
47
+ return null;
48
+ }
49
+
50
+ export function ContentBreadcrumbs({
51
+ currentPath,
52
+ sidebarEntry,
53
+ }: {
54
+ currentPath: string;
55
+ sidebarEntry: StarlightRouteData['sidebar'];
56
+ }) {
57
+ const breadcrumbs = findBreadcrumbTrail(sidebarEntry, currentPath, true);
58
+
59
+ if (!breadcrumbs) {
60
+ return null;
61
+ }
62
+
63
+ const items = breadcrumbs?.map((crumb, index) => (
64
+ <div key={index} className={style.BreadcrumbsItem}>
65
+ {crumb.href ? (
66
+ <a href={crumb.href} className={style.BreadcrumbsLink}>
67
+ {crumb.title}
68
+ </a>
69
+ ) : (
70
+ <span className={style.BreadcrumbsNonLink}>{crumb.title}</span>
71
+ )}
72
+ </div>
73
+ ));
74
+
75
+ return (
76
+ <div className="stl-content-breadcrumbs stldocs-root">
77
+ <div className={style.Breadcrumbs}>
78
+ <Join limit={breadcrumbs?.length} items={items}>
79
+ <ChevronRight />
80
+ </Join>
81
+ </div>
82
+ </div>
83
+ );
84
+ }
@@ -0,0 +1,72 @@
1
+ ---
2
+ import { ContentBreadcrumbs } from './ContentBreadcrumbs';
3
+ import { ProseAIDropdown } from './ProseAIDropdown';
4
+ const currentPath = Astro.url.pathname;
5
+ ---
6
+
7
+ <div class="content-panel">
8
+ <div class="sl-container stl-ui-prose">
9
+ <div class="stl-ui-not-prose stl-page-nav-container stl-prose-page-nav-container">
10
+ <ContentBreadcrumbs currentPath={currentPath} sidebarEntry={Astro.locals.starlightRoute.sidebar} />
11
+ <ProseAIDropdown currentPath={currentPath} sidebarEntry={Astro.locals.starlightRoute.sidebar} />
12
+ </div>
13
+ <slot />
14
+ </div>
15
+ </div>
16
+
17
+ <style>
18
+ @layer starlight.core {
19
+ .content-panel {
20
+ padding: 1.5rem var(--sl-content-pad-x);
21
+ }
22
+ .content-panel + .content-panel {
23
+ border-top: 1px solid var(--sl-color-hairline);
24
+ }
25
+ .sl-container {
26
+ max-width: var(--sl-content-width);
27
+ }
28
+
29
+ .sl-container > :global(* + *) {
30
+ margin-top: 1.5rem;
31
+ }
32
+
33
+ @media (min-width: 72rem) {
34
+ .sl-container {
35
+ margin-inline: var(--sl-content-margin-inline, auto);
36
+ }
37
+ }
38
+ }
39
+ /* Overrides */
40
+ @layer stainless {
41
+ .content-panel {
42
+ padding: 0 var(--sl-content-pad-x);
43
+ }
44
+
45
+ .stl-prose-page-nav-container {
46
+ padding: 1rem 0 0;
47
+ }
48
+ }
49
+ </style>
50
+
51
+ <style is:global>
52
+ .content-panel:nth-of-type(2) .stl-page-nav-container {
53
+ display: none;
54
+ }
55
+ </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>
@@ -0,0 +1,64 @@
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
+ }
@@ -0,0 +1,36 @@
1
+ ---
2
+ import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
3
+ import Search from 'virtual:starlight/components/Search';
4
+ import SiteTitle from 'virtual:starlight/components/SiteTitle';
5
+ import HeaderLinks from './HeaderLinks.astro';
6
+ import NavLinks from '../nav-tabs/NavTabs.astro';
7
+ import { TABS } from 'virtual:stl-stl-starlight-virtual-module';
8
+ import ThemeSelect from 'virtual:starlight/components/ThemeSelect';
9
+ import SplashMobileMenuToggle from './SplashMobileMenuToggle.astro';
10
+
11
+ interface Props {
12
+ shouldRenderSearch?: boolean;
13
+ }
14
+
15
+ const { shouldRenderSearch } = Astro.props;
16
+ const { hasSidebar } = Astro.locals.starlightRoute;
17
+ ---
18
+
19
+ <div class="header my-header">
20
+ <div class="left-group">
21
+ <div class="title-wrapper sl-flex">
22
+ <SiteTitle />
23
+ </div>
24
+ </div>
25
+ {TABS.length > 0 && <NavLinks />}
26
+
27
+ <div class={'sl-flex print:hidden right-group default-tabs-container'}>
28
+ {shouldRenderSearch && <Search />}
29
+ {!hasSidebar && <SplashMobileMenuToggle />}
30
+ <div class="sl-hidden md:sl-flex">
31
+ <ThemeSelect />
32
+ <HeaderLinks />
33
+ <LanguageSelect />
34
+ </div>
35
+ </div>
36
+ </div>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { HEADER_LINKS } from 'virtual:stl-stl-starlight-virtual-module';
3
+ import { Button } from '@stainless-api/ui-primitives';
4
+ ---
5
+
6
+ {
7
+ HEADER_LINKS.map((link, index) => (
8
+ <Button
9
+ href={link.link}
10
+ variant={link.variant || (index === HEADER_LINKS.length - 1 ? 'accent' : 'outline')}
11
+ {...(link.attrs || {})}
12
+ >
13
+ <Button.Label>{link.label}</Button.Label>
14
+ </Button>
15
+ ))
16
+ }
@@ -0,0 +1,49 @@
1
+ ---
2
+ import MobileMenuToggle from 'virtual:starlight/components/MobileMenuToggle';
3
+ import Sidebar from 'virtual:starlight/components/Sidebar';
4
+ ---
5
+
6
+ <div class="stl-splash-mobile-menu-toggle">
7
+ <MobileMenuToggle />
8
+ <div id="starlight__sidebar" class="sidebar-pane">
9
+ <div class="sidebar-content sl-flex">
10
+ <Sidebar />
11
+ </div>
12
+ </div>
13
+ </div>
14
+
15
+ <style>
16
+ :global([aria-expanded='true']) ~ .sidebar-pane {
17
+ --sl-sidebar-visibility: visible;
18
+ }
19
+ .sidebar-pane {
20
+ visibility: var(--sl-sidebar-visibility, hidden);
21
+ position: fixed;
22
+ z-index: var(--sl-z-index-menu);
23
+ inset-block: var(--sl-nav-height) 0;
24
+ inset-inline-start: 0;
25
+ width: 100%;
26
+ overflow-y: auto;
27
+ }
28
+
29
+ .sidebar-content {
30
+ height: 100%;
31
+ min-height: max-content;
32
+ padding: 1rem var(--sl-sidebar-pad-x) 0;
33
+ flex-direction: column;
34
+ gap: 1rem;
35
+ }
36
+
37
+ @media (min-width: 50rem) {
38
+ .stl-splash-mobile-menu-toggle {
39
+ display: none;
40
+ }
41
+ }
42
+ </style>
43
+ <style is:global>
44
+ .stl-splash-mobile-menu-toggle button {
45
+ position: relative;
46
+ top: unset;
47
+ inset-inline-end: unset;
48
+ }
49
+ </style>
@@ -0,0 +1,75 @@
1
+ ---
2
+ import LanguageSelect from "virtual:starlight/components/LanguageSelect";
3
+ import Search from "virtual:starlight/components/Search";
4
+ import SiteTitle from "virtual:starlight/components/SiteTitle";
5
+ import HeaderLinks from './HeaderLinks.astro';
6
+ import { TABS } from "virtual:stl-stl-starlight-virtual-module";
7
+ import ThemeSelect from "virtual:starlight/components/ThemeSelect";
8
+ import SecondaryNavTabs from "../nav-tabs/SecondaryNavTabs.astro";
9
+ import SplashMobileMenuToggle from "./SplashMobileMenuToggle.astro";
10
+
11
+ interface Props {
12
+ shouldRenderSearch?: boolean;
13
+ }
14
+
15
+ const { shouldRenderSearch } = Astro.props;
16
+ const { hasSidebar } = Astro.locals.starlightRoute;
17
+ ---
18
+
19
+ <div class="header my-header">
20
+ <div class="left-group">
21
+ <div class="title-wrapper sl-flex">
22
+ <SiteTitle />
23
+ </div>
24
+ </div>
25
+
26
+ <div class="stl-top-container">
27
+ {shouldRenderSearch && <Search />}
28
+ {!hasSidebar && <SplashMobileMenuToggle />}
29
+ </div>
30
+
31
+ <div class={`sl-hidden md:sl-flex print:hidden right-group`}>
32
+ <ThemeSelect />
33
+ <HeaderLinks />
34
+ <LanguageSelect />
35
+ </div>
36
+ </div>
37
+
38
+ <SecondaryNavTabs />
39
+
40
+ <style is:inline>
41
+ .stl-top-container {
42
+ display: flex;
43
+ flex-direction: row;
44
+ align-items: center;
45
+ justify-content: end;
46
+ gap: 0.5rem;
47
+ width: 100%;
48
+ }
49
+ @media (min-width: 50rem) {
50
+ :root {
51
+ --sl-nav-height: 88px;
52
+ }
53
+
54
+ header.header {
55
+ display: flex;
56
+ flex-direction: column;
57
+ gap: 0.29rem;
58
+ padding-bottom: 0;
59
+ }
60
+
61
+ .stl-top-container {
62
+ justify-content: center;
63
+ }
64
+ }
65
+ </style>
66
+
67
+ {TABS.length === 0 && (
68
+ <style is:inline>
69
+ @media (min-width: 50rem) {
70
+ :root {
71
+ --sl-nav-height: 56px;
72
+ }
73
+ }
74
+ </style>
75
+ )}
@@ -0,0 +1,46 @@
1
+ ---
2
+ export interface Props {
3
+ title: string;
4
+ }
5
+
6
+ const { title } = Astro.props;
7
+ ---
8
+
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>
14
+ </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>