@stainless-api/docs 0.1.0-beta.120 → 0.1.0-beta.121
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 +14 -0
- package/package.json +5 -5
- package/plugin/components/search/SearchIsland.tsx +14 -13
- package/stl-docs/index.ts +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @stainless-api/docs
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.121
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9cb2166: Join base path with HEADER_LINKS and TABS
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 7701d8f: Clean up console warnings loading DocsSearch markdown renderer
|
|
12
|
+
- Updated dependencies [7701d8f]
|
|
13
|
+
- Updated dependencies [5460e81]
|
|
14
|
+
- @stainless-api/docs-ui@0.1.0-beta.87
|
|
15
|
+
- @stainless-api/docs-search@0.1.0-beta.40
|
|
16
|
+
|
|
3
17
|
## 0.1.0-beta.120
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stainless-api/docs",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.121",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"cheerio": "^1.2.0",
|
|
49
49
|
"clsx": "^2.1.1",
|
|
50
50
|
"dotenv": "17.3.1",
|
|
51
|
-
"lucide-react": "^0.
|
|
51
|
+
"lucide-react": "^0.577.0",
|
|
52
52
|
"marked": "^17.0.4",
|
|
53
|
-
"node-html-parser": "^7.0
|
|
53
|
+
"node-html-parser": "^7.1.0",
|
|
54
54
|
"rehype-parse": "^9.0.1",
|
|
55
55
|
"rehype-remark": "^10.0.1",
|
|
56
56
|
"remark-gfm": "^4.0.1",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"vite-plugin-prebundle-workers": "^0.2.0",
|
|
62
62
|
"web-worker": "^1.5.0",
|
|
63
63
|
"yaml": "^2.8.2",
|
|
64
|
-
"@stainless-api/docs-search": "0.1.0-beta.
|
|
65
|
-
"@stainless-api/docs-ui": "0.1.0-beta.
|
|
64
|
+
"@stainless-api/docs-search": "0.1.0-beta.40",
|
|
65
|
+
"@stainless-api/docs-ui": "0.1.0-beta.87",
|
|
66
66
|
"@stainless-api/ui-primitives": "0.1.0-beta.50"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { RESOLVED_API_REFERENCE_PATH, HIGHLIGHT_THEMES } from 'virtual:stl-starlight-virtual-module';
|
|
3
3
|
import { parseRoute, generateRoute } from '@stainless-api/docs-ui/routing';
|
|
4
4
|
import { SearchModal } from '@stainless-api/docs-search';
|
|
@@ -8,27 +8,28 @@ import type { BundledLanguage, BundledTheme, HighlighterGeneric } from 'shiki';
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
DocsProvider,
|
|
11
|
-
type
|
|
12
|
-
MarkdownProvider,
|
|
11
|
+
type MarkdownContextValue,
|
|
13
12
|
NavigationProvider,
|
|
13
|
+
SuspensefulMarkdownProvider,
|
|
14
14
|
} from '@stainless-api/docs-ui/contexts';
|
|
15
15
|
import { ComponentProvider } from '@stainless-api/docs-ui/contexts/component';
|
|
16
16
|
import { SearchProvider } from '@stainless-api/docs-search/context';
|
|
17
17
|
import type { SearchSettings } from '@stainless-api/docs-search/types';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
declare global {
|
|
20
|
+
var __docsSearchShikiSingleton: Promise<HighlighterGeneric<BundledLanguage, BundledTheme>> | undefined;
|
|
21
|
+
}
|
|
22
|
+
function getHighlighter() {
|
|
23
|
+
if (!globalThis.__docsSearchShikiSingleton) {
|
|
24
|
+
globalThis.__docsSearchShikiSingleton = createHighlighter({
|
|
23
25
|
themes: ['github-dark'],
|
|
24
26
|
langs: ['typescript', 'python', 'go', 'java', 'kotlin', 'ruby'],
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
return $$highlighter;
|
|
29
|
+
return globalThis.__docsSearchShikiSingleton;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
async function createMarkdownRenderer(): Promise<
|
|
32
|
+
async function createMarkdownRenderer(): Promise<MarkdownContextValue> {
|
|
32
33
|
const highlighter = await getHighlighter();
|
|
33
34
|
const markdocConfig: Markdoc.Config = {
|
|
34
35
|
nodes: {
|
|
@@ -91,7 +92,7 @@ async function createMarkdownRenderer(): Promise<MarkdownContext> {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
export function DocsSearch({ settings, currentPath }: { settings: SearchSettings; currentPath: string }) {
|
|
94
|
-
const
|
|
95
|
+
const rendererPromise = useMemo(() => createMarkdownRenderer(), []);
|
|
95
96
|
const { stainlessPath, language } = parseRoute(RESOLVED_API_REFERENCE_PATH, currentPath);
|
|
96
97
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
97
98
|
const pageFind = import.meta.env.DEV
|
|
@@ -109,13 +110,13 @@ export function DocsSearch({ settings, currentPath }: { settings: SearchSettings
|
|
|
109
110
|
<DocsProvider spec={null} language={language}>
|
|
110
111
|
<ComponentProvider>
|
|
111
112
|
<NavigationProvider basePath="/" selectedPath={stainlessPath}>
|
|
112
|
-
<
|
|
113
|
+
<SuspensefulMarkdownProvider value={rendererPromise}>
|
|
113
114
|
<SearchProvider onSelect={handleSelect} pageFind={pageFind} settings={settings}>
|
|
114
115
|
<div className="stldocs-root">
|
|
115
116
|
<SearchModal id="stldocs-search" />
|
|
116
117
|
</div>
|
|
117
118
|
</SearchProvider>
|
|
118
|
-
</
|
|
119
|
+
</SuspensefulMarkdownProvider>
|
|
119
120
|
</NavigationProvider>
|
|
120
121
|
</ComponentProvider>
|
|
121
122
|
</DocsProvider>
|
package/stl-docs/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { disableCalloutSyntaxStarlightPlugin } from './disableCalloutSyntax';
|
|
|
6
6
|
import type { AstroIntegration } from 'astro';
|
|
7
7
|
|
|
8
8
|
import { normalizeRedirects, type NormalizedRedirectConfig } from './redirects';
|
|
9
|
-
import
|
|
9
|
+
import path from 'node:path';
|
|
10
10
|
import { mkdirSync, writeFileSync } from 'fs';
|
|
11
11
|
import {
|
|
12
12
|
parseStlDocsConfig,
|
|
@@ -175,12 +175,18 @@ function stainlessDocsIntegration(
|
|
|
175
175
|
redirects = normalizeRedirects(astroConfig.redirects);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
const base = astroConfig.base ?? '/';
|
|
179
|
+
const withBase = (link: string) =>
|
|
180
|
+
['http://', 'https://', '//'].some((prefix) => link.startsWith(prefix))
|
|
181
|
+
? link
|
|
182
|
+
: path.posix.join(base, link);
|
|
183
|
+
|
|
178
184
|
const virtualModules = new Map(
|
|
179
185
|
Object.entries({
|
|
180
186
|
'virtual:stl-docs-virtual-module': buildVirtualModuleString({
|
|
181
|
-
TABS: config.tabs,
|
|
187
|
+
TABS: config.tabs.map((tab) => ({ ...tab, link: withBase(tab.link) })),
|
|
182
188
|
SPLIT_TABS_ENABLED: config.splitTabsEnabled,
|
|
183
|
-
HEADER_LINKS: config.header.links,
|
|
189
|
+
HEADER_LINKS: config.header.links.map((link) => ({ ...link, link: withBase(link.link) })),
|
|
184
190
|
HEADER_LAYOUT: config.header.layout,
|
|
185
191
|
ENABLE_CLIENT_ROUTER: config.enableClientRouter,
|
|
186
192
|
API_REFERENCE_BASE_PATH: apiReferenceBasePath ?? '/api',
|
|
@@ -240,9 +246,9 @@ function stainlessDocsIntegration(
|
|
|
240
246
|
},
|
|
241
247
|
'astro:build:done': ({ dir }) => {
|
|
242
248
|
if (redirects !== null) {
|
|
243
|
-
const stainlessDir = join(dir.pathname, '_stainless');
|
|
249
|
+
const stainlessDir = path.join(dir.pathname, '_stainless');
|
|
244
250
|
mkdirSync(stainlessDir, { recursive: true });
|
|
245
|
-
const outputPath = join(stainlessDir, 'redirects.json');
|
|
251
|
+
const outputPath = path.join(stainlessDir, 'redirects.json');
|
|
246
252
|
writeFileSync(outputPath, JSON.stringify(redirects, null, 2), {
|
|
247
253
|
encoding: 'utf-8',
|
|
248
254
|
});
|