@stainless-api/docs 0.1.0-beta.6 → 0.1.0-beta.61
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 +486 -0
- package/README.md +1 -1
- package/eslint-suppressions.json +52 -0
- package/locals.d.ts +16 -0
- package/package.json +45 -40
- package/plugin/assets/languages/csharp.svg +1 -0
- package/plugin/buildAlgoliaIndex.ts +32 -7
- package/plugin/cms/server.ts +130 -58
- package/plugin/cms/sidebar-builder.ts +7 -26
- package/plugin/cms/worker.ts +83 -5
- package/plugin/components/MethodDescription.tsx +54 -0
- package/plugin/components/SDKSelect.astro +7 -87
- package/plugin/components/SnippetCode.tsx +53 -8
- package/plugin/components/search/SearchAlgolia.astro +14 -26
- package/plugin/components/search/SearchIsland.tsx +38 -24
- package/plugin/create-playground.shim.tsx +3 -0
- package/plugin/generateAPIReferenceLink.ts +2 -2
- package/plugin/globalJs/ai-dropdown-options.ts +235 -0
- package/plugin/globalJs/code-snippets.ts +15 -8
- package/plugin/globalJs/copy.ts +81 -16
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +7 -4
- package/plugin/index.ts +179 -35
- package/plugin/languages.ts +5 -2
- package/plugin/loadPluginConfig.ts +121 -32
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +1 -1
- package/plugin/react/Routing.tsx +208 -104
- package/plugin/referencePlaceholderUtils.ts +1 -1
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +5 -1
- package/plugin/routes/Docs.astro +61 -83
- package/plugin/routes/Overview.astro +10 -16
- package/plugin/routes/markdown.ts +7 -7
- package/plugin/vendor/preview.worker.docs.js +19768 -17702
- package/plugin/vendor/templates/go.md +1 -1
- package/plugin/vendor/templates/python.md +1 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +5 -5
- package/shared/getSharedLogger.ts +15 -0
- package/shared/terminalUtils.ts +3 -0
- package/src/content.config.ts +9 -0
- package/stl-docs/components/AIDropdown.tsx +63 -0
- package/stl-docs/components/AiChatIsland.tsx +10 -0
- package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +10 -18
- package/stl-docs/components/Head.astro +16 -0
- package/stl-docs/components/Header.astro +6 -8
- package/stl-docs/components/PageFrame.astro +14 -0
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/TableOfContents.astro +34 -0
- package/stl-docs/components/ThemeSelect.astro +118 -136
- package/stl-docs/components/content-panel/ContentPanel.astro +16 -25
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +17 -1
- package/stl-docs/components/headers/StackedHeader.astro +29 -24
- package/stl-docs/components/icons/chat-gpt.tsx +17 -0
- package/stl-docs/components/icons/claude.tsx +10 -0
- package/stl-docs/components/icons/cursor.tsx +10 -0
- package/stl-docs/components/icons/gemini.tsx +19 -0
- package/stl-docs/components/icons/markdown.tsx +10 -0
- package/stl-docs/components/index.ts +1 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +7 -5
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +7 -3
- package/stl-docs/components/mintlify-compat/Columns.astro +40 -42
- package/stl-docs/components/mintlify-compat/Frame.astro +16 -18
- package/stl-docs/components/mintlify-compat/Step.astro +30 -32
- package/stl-docs/components/mintlify-compat/Steps.astro +8 -10
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +1 -1
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +1 -1
- package/stl-docs/components/mintlify-compat/card.css +33 -35
- package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -70
- package/stl-docs/components/nav-tabs/NavTabs.astro +78 -80
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -8
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +3 -2
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +175 -0
- package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
- package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
- package/stl-docs/components/pagination/util.ts +71 -0
- package/stl-docs/components/scripts.ts +1 -0
- package/stl-docs/disableCalloutSyntax.ts +36 -0
- package/stl-docs/index.ts +130 -48
- package/stl-docs/loadStlDocsConfig.ts +44 -4
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +64 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +34 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/proseSearchIndexing.ts +113 -0
- package/stl-docs/tabsMiddleware.ts +11 -3
- package/styles/code.css +108 -140
- package/styles/fonts.css +32 -17
- package/styles/links.css +11 -48
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +48 -60
- package/styles/page.css +92 -52
- package/styles/sdk_select.css +9 -7
- package/styles/search.css +58 -69
- package/styles/sidebar.css +211 -131
- package/styles/{variables.css → sl-variables.css} +3 -2
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +41 -34
- package/theme.css +10 -10
- package/tsconfig.json +2 -5
- package/virtual-module.d.ts +23 -3
- package/components/variables.css +0 -135
- /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
|
@@ -7,80 +7,98 @@ import clsx from 'clsx';
|
|
|
7
7
|
const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
<div id="nav-links-container">
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<ul class="nav-links" id="nav-links-test-container">
|
|
32
|
-
{
|
|
33
|
-
navLinks.map((item) => (
|
|
34
|
-
<li>
|
|
35
|
-
<Button href={item.link} className={clsx('nav-link')} variant={item.active ? 'accent' : 'ghost'}>
|
|
36
|
-
<span>{item.label}</span>
|
|
37
|
-
</Button>
|
|
38
|
-
</li>
|
|
39
|
-
))
|
|
40
|
-
}
|
|
41
|
-
</ul>
|
|
10
|
+
<div id="nav-links-container" class="nav-links-container">
|
|
11
|
+
<div class="desktop-nav-links-container">
|
|
12
|
+
<ul class="nav-links" id="nav-links-list">
|
|
13
|
+
{
|
|
14
|
+
navLinks.map((item) => (
|
|
15
|
+
<li data-desktop-only>
|
|
16
|
+
<Button
|
|
17
|
+
href={item.link}
|
|
18
|
+
className={clsx('nav-link')}
|
|
19
|
+
variant={item.active ? 'accent-muted' : 'ghost'}
|
|
20
|
+
>
|
|
21
|
+
<span>{item.label}</span>
|
|
22
|
+
</Button>
|
|
23
|
+
</li>
|
|
24
|
+
))
|
|
25
|
+
}
|
|
26
|
+
</ul>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="mobile-nav-dropdown" data-mobile-only>
|
|
29
|
+
<NavDropdown />
|
|
30
|
+
</div>
|
|
42
31
|
</div>
|
|
43
32
|
|
|
44
33
|
<script>
|
|
45
34
|
import { getPageLoadEvent } from '../../../plugin/helpers/getPageLoadEvent';
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
// We need to measure the nav links to see if they fit. We create an offscreen hidden clone for measurement.
|
|
37
|
+
function createOffscreenClone(element: HTMLElement): HTMLElement {
|
|
38
|
+
const clone = element.cloneNode(true) as HTMLElement;
|
|
39
|
+
clone.removeAttribute('id');
|
|
40
|
+
clone.id = 'cloned-nav-links-measurement';
|
|
41
|
+
clone.style.position = 'absolute';
|
|
42
|
+
clone.style.visibility = 'hidden';
|
|
43
|
+
clone.style.top = '0';
|
|
44
|
+
clone.style.left = '0';
|
|
45
|
+
clone.style.width = 'auto';
|
|
46
|
+
clone.style.whiteSpace = 'nowrap';
|
|
47
|
+
clone.style.pointerEvents = 'none';
|
|
48
|
+
clone.style.zIndex = '-9999';
|
|
49
|
+
|
|
50
|
+
clone.querySelectorAll('[data-desktop-only], [data-mobile-only]').forEach((el) => {
|
|
51
|
+
el.removeAttribute('data-desktop-only');
|
|
52
|
+
});
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return rw;
|
|
54
|
+
document.body.appendChild(clone);
|
|
55
|
+
return clone;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
function initNavbar() {
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
+
const navLinksContainer = document.getElementById('nav-links-container');
|
|
60
|
+
if (!navLinksContainer) {
|
|
61
|
+
console.error(`NavTabs: #nav-links-container not found`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
59
64
|
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
65
|
+
const navLinksList = document.getElementById('nav-links-list');
|
|
66
|
+
if (!navLinksList) {
|
|
67
|
+
console.error(`NavTabs: #nav-links-list not found`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const measurementClone = createOffscreenClone(navLinksList);
|
|
72
|
+
const requiredWidth = measurementClone.clientWidth;
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
let currentMode: 'desktop' | 'mobile' | null = null;
|
|
64
75
|
|
|
65
76
|
function checkIfFits() {
|
|
66
|
-
if (!masterContainer) return;
|
|
67
77
|
if (!navLinksContainer) return;
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
|
|
79
|
+
// 16px buffer helps it feel less crowded before switching modes
|
|
80
|
+
const bufferSpace = 16;
|
|
81
|
+
const availableWidth = navLinksContainer.clientWidth;
|
|
82
|
+
const canFit = availableWidth - bufferSpace >= requiredWidth;
|
|
70
83
|
|
|
71
84
|
const mode = canFit ? 'desktop' : 'mobile';
|
|
72
85
|
|
|
73
|
-
|
|
86
|
+
// Only update if mode actually changed
|
|
87
|
+
if (mode === currentMode) return;
|
|
88
|
+
|
|
89
|
+
currentMode = mode;
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
document.documentElement.classList.remove('stl-nav-links-mode-mobile');
|
|
91
|
+
localStorage.setItem('stl-nav-links-mode', mode);
|
|
77
92
|
|
|
93
|
+
document.documentElement.classList.remove('stl-nav-links-mode-desktop', 'stl-nav-links-mode-mobile');
|
|
78
94
|
document.documentElement.classList.add('stl-nav-links-mode-' + mode);
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
82
98
|
checkIfFits();
|
|
83
99
|
});
|
|
100
|
+
|
|
101
|
+
resizeObserver.observe(navLinksContainer);
|
|
84
102
|
checkIfFits();
|
|
85
103
|
}
|
|
86
104
|
|
|
@@ -109,55 +127,35 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
109
127
|
</style>
|
|
110
128
|
|
|
111
129
|
<style>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
.nav-links-container {
|
|
131
|
+
flex-grow: 1;
|
|
132
|
+
margin-left: 1rem;
|
|
133
|
+
margin-right: 1rem;
|
|
134
|
+
}
|
|
115
135
|
|
|
116
|
-
|
|
117
|
-
visibility: hidden;
|
|
136
|
+
.desktop-nav-links-container {
|
|
118
137
|
display: flex;
|
|
119
138
|
flex-grow: 1;
|
|
120
139
|
justify-content: flex-start;
|
|
121
140
|
overflow: hidden;
|
|
122
|
-
margin-left: 1rem;
|
|
123
|
-
margin-right: 1rem;
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
.nav-links {
|
|
127
144
|
display: flex;
|
|
128
145
|
list-style: none;
|
|
129
|
-
gap:
|
|
146
|
+
gap: 4px;
|
|
130
147
|
padding: 0;
|
|
131
148
|
margin: 0;
|
|
132
149
|
white-space: nowrap;
|
|
133
150
|
overflow: hidden;
|
|
134
151
|
}
|
|
135
152
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
top: 0;
|
|
139
|
-
left: 0;
|
|
140
|
-
visibility: hidden;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.nav-links li {
|
|
144
|
-
display: flex;
|
|
145
|
-
align-items: center;
|
|
146
|
-
justify-content: center;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.nav-link {
|
|
150
|
-
text-decoration: none;
|
|
151
|
-
flex: 1;
|
|
152
|
-
|
|
153
|
-
&.stl-ui-button--ghost:hover {
|
|
154
|
-
color: var(--sl-color-text-accent);
|
|
155
|
-
background-color: transparent;
|
|
156
|
-
}
|
|
153
|
+
.mobile-nav-dropdown {
|
|
154
|
+
flex-grow: 1;
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
@media (min-width: 50rem) {
|
|
160
|
-
|
|
158
|
+
.desktop-nav-links-container {
|
|
161
159
|
display: flex;
|
|
162
160
|
visibility: visible;
|
|
163
161
|
}
|
|
@@ -34,13 +34,7 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
34
34
|
align-items: center;
|
|
35
35
|
padding: 0;
|
|
36
36
|
list-style: none;
|
|
37
|
-
overflow-x: auto;
|
|
38
37
|
margin-bottom: -1px;
|
|
39
|
-
gap: 0.29rem;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.stl-active-secondary-link:hover {
|
|
43
|
-
background-color: transparent;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
li {
|
|
@@ -48,7 +42,21 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
48
42
|
border-bottom: 2px solid transparent;
|
|
49
43
|
|
|
50
44
|
&.active {
|
|
51
|
-
border-color: var(--
|
|
45
|
+
border-color: var(--stl-color-accent-border-strong);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.stl-ui-button {
|
|
49
|
+
/* match sidebar. TODO: hoist sidebar variables to use those instead of hardcoding? */
|
|
50
|
+
border-width: 0;
|
|
51
|
+
padding: 8px 12px;
|
|
52
|
+
margin-inline: -12px;
|
|
53
|
+
}
|
|
54
|
+
/* cover for button’s negative margin */
|
|
55
|
+
&:not(:first-child) {
|
|
56
|
+
margin-inline-start: 12px;
|
|
57
|
+
}
|
|
58
|
+
&:not(:last-child) {
|
|
59
|
+
margin-inline-end: 12px;
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -56,7 +64,6 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
56
64
|
@media (min-width: 50rem) {
|
|
57
65
|
.stl-secondary-nav-tabs {
|
|
58
66
|
display: block;
|
|
59
|
-
padding-left: 0.55rem;
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
</style>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
2
2
|
import { TABS } from 'virtual:stl-docs-virtual-module';
|
|
3
|
+
import type { StarlightRouteWithStlDocs } from '../../tabsMiddleware';
|
|
3
4
|
|
|
4
5
|
export function buildNavLinks(starlightRoute: StarlightRouteData) {
|
|
5
|
-
|
|
6
|
-
const activeTabIndex =
|
|
6
|
+
const routeData: StarlightRouteWithStlDocs = starlightRoute;
|
|
7
|
+
const activeTabIndex = routeData?._stlDocs?.activeTabIndex;
|
|
7
8
|
|
|
8
9
|
const navLinks = TABS.map((item, index) => ({
|
|
9
10
|
...item,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { base } from 'astro:config/client';
|
|
3
|
+
import { HomeIcon } from 'lucide-react';
|
|
4
|
+
import PaginationLinkQuiet from './PaginationLinkQuiet.astro';
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<PaginationLinkQuiet href={base}>
|
|
8
|
+
<HomeIcon slot="icon" />
|
|
9
|
+
Home
|
|
10
|
+
</PaginationLinkQuiet>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
import HomeLink from './HomeLink.astro';
|
|
3
|
+
import PaginationLinkEmphasized from './PaginationLinkEmphasized.astro';
|
|
4
|
+
|
|
5
|
+
import { getPrevNextPage } from './util';
|
|
6
|
+
import config from 'virtual:starlight/user-config';
|
|
7
|
+
const { prev, next } = (await getPrevNextPage(Astro.locals.starlightRoute, config.pagination)) ?? {};
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
next || prev ? (
|
|
12
|
+
<div class="pagination-links print:hidden stl-ui-not-prose">
|
|
13
|
+
{/* Previous */}
|
|
14
|
+
{!prev && <HomeLink />}
|
|
15
|
+
{/* TODO: intelligently decide whether or not to emphasize the previous page - including user config option (page level?) */}
|
|
16
|
+
{/* {prev && next && (
|
|
17
|
+
<PaginationLinkQuiet href={prev.href}>
|
|
18
|
+
<ChevronLeftIcon slot="icon" />
|
|
19
|
+
Previous
|
|
20
|
+
</PaginationLinkQuiet>
|
|
21
|
+
)} */}
|
|
22
|
+
{prev && (
|
|
23
|
+
<PaginationLinkEmphasized href={prev.href} direction="prev">
|
|
24
|
+
<h2 slot="page-title">{prev.label}</h2>
|
|
25
|
+
{prev.description && <p slot="page-description">{prev.description}</p>}
|
|
26
|
+
</PaginationLinkEmphasized>
|
|
27
|
+
)}
|
|
28
|
+
|
|
29
|
+
{/* Next */}
|
|
30
|
+
{!next && <HomeLink />}
|
|
31
|
+
{next && (
|
|
32
|
+
<PaginationLinkEmphasized href={next.href} direction="next">
|
|
33
|
+
<h2 slot="page-title">{next.label}</h2>
|
|
34
|
+
{next.description && <p slot="page-description">{next.description}</p>}
|
|
35
|
+
</PaginationLinkEmphasized>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
) : null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
<style is:global>
|
|
42
|
+
@layer starlight.core {
|
|
43
|
+
.pagination-links,
|
|
44
|
+
.pagination-links a,
|
|
45
|
+
.pagination-links a:hover,
|
|
46
|
+
.pagination-links a[rel='next'],
|
|
47
|
+
.link-title {
|
|
48
|
+
all: revert-layer;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.pagination-links {
|
|
53
|
+
--stl-ui-pagination-padding: 8px;
|
|
54
|
+
--stl-ui-pagination-border-radius-inner: var(--stl-ui-layout-border-radius-sml);
|
|
55
|
+
|
|
56
|
+
padding: var(--stl-ui-pagination-padding);
|
|
57
|
+
background-color: var(--stl-color-faint-background);
|
|
58
|
+
border: 1px solid var(--stl-color-border);
|
|
59
|
+
border-radius: calc(var(--stl-ui-pagination-border-radius-inner) + var(--stl-ui-pagination-padding));
|
|
60
|
+
|
|
61
|
+
font-size: var(--stl-typography-scale-sm);
|
|
62
|
+
letter-spacing: normal;
|
|
63
|
+
|
|
64
|
+
display: flex;
|
|
65
|
+
gap: 8px;
|
|
66
|
+
|
|
67
|
+
margin-bottom: 2rem;
|
|
68
|
+
color: inherit; /* stl-ui-not-prose sets color: initial */
|
|
69
|
+
|
|
70
|
+
a {
|
|
71
|
+
border-radius: var(--stl-ui-pagination-border-radius-inner);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.pagination-links__link {
|
|
76
|
+
display: flex;
|
|
77
|
+
border-radius: var(--stl-ui-pagination-border-radius-inner);
|
|
78
|
+
padding: 8px 12px;
|
|
79
|
+
display: flex;
|
|
80
|
+
text-decoration: none;
|
|
81
|
+
align-items: center;
|
|
82
|
+
color: inherit;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.pagination-links__link--emphasized {
|
|
86
|
+
background-color: var(--stl-color-background);
|
|
87
|
+
border: 1px solid var(--stl-color-border);
|
|
88
|
+
flex: 1 1 50%;
|
|
89
|
+
gap: 12px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.pagination-links__link--quiet {
|
|
93
|
+
flex: 0 1 auto;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.pagination-links__button {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
padding: 8px 14px;
|
|
100
|
+
font-weight: 500;
|
|
101
|
+
line-height: 1;
|
|
102
|
+
|
|
103
|
+
svg {
|
|
104
|
+
width: 16px;
|
|
105
|
+
height: 16px;
|
|
106
|
+
margin-block: -4px;
|
|
107
|
+
margin-inline-start: -6px;
|
|
108
|
+
margin-inline-end: 6px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&.pagination-links__link--quiet {
|
|
112
|
+
padding-inline: 22px;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.pagination-links__link__divider {
|
|
117
|
+
border: 0;
|
|
118
|
+
border-inline-start: 1px solid var(--stl-color-border);
|
|
119
|
+
align-self: stretch;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.pagination-links__page-description {
|
|
123
|
+
padding-block: 4px;
|
|
124
|
+
padding-inline-start: 8px;
|
|
125
|
+
padding-inline-end: 2px;
|
|
126
|
+
line-height: 1.5;
|
|
127
|
+
flex: 1 1 50%;
|
|
128
|
+
width: 0;
|
|
129
|
+
|
|
130
|
+
h2,
|
|
131
|
+
p {
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
text-overflow: ellipsis;
|
|
135
|
+
}
|
|
136
|
+
h2 {
|
|
137
|
+
font-size: inherit;
|
|
138
|
+
font-weight: 500;
|
|
139
|
+
}
|
|
140
|
+
p {
|
|
141
|
+
font-size: var(--stl-typography-scale-xs);
|
|
142
|
+
color: var(--stl-color-foreground-muted);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
.pagination-links__link--quiet:hover {
|
|
146
|
+
background-color: var(--stl-color-background-hover);
|
|
147
|
+
}
|
|
148
|
+
.pagination-links__link--emphasized:hover {
|
|
149
|
+
border-color: var(--stl-color-border-strong);
|
|
150
|
+
.pagination-links__page-description h2 {
|
|
151
|
+
text-decoration: underline;
|
|
152
|
+
text-decoration-color: var(--stl-color-foreground-reduced);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* “next” link runs the opposite direction of the “previous” link */
|
|
157
|
+
.pagination-links__link:last-child {
|
|
158
|
+
flex-direction: row-reverse;
|
|
159
|
+
|
|
160
|
+
&.pagination-links__button,
|
|
161
|
+
.pagination-links__button {
|
|
162
|
+
flex-direction: row-reverse;
|
|
163
|
+
svg {
|
|
164
|
+
margin-inline-start: 6px;
|
|
165
|
+
margin-inline-end: -6px;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.pagination-links__page-description {
|
|
170
|
+
padding-inline-start: 2px;
|
|
171
|
+
padding-inline-end: 8px;
|
|
172
|
+
text-align: right;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
|
|
3
|
+
const { href, direction } = Astro.props;
|
|
4
|
+
export interface Props {
|
|
5
|
+
href: string;
|
|
6
|
+
direction: 'prev' | 'next';
|
|
7
|
+
}
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<a href={href} class="pagination-links__link pagination-links__link--emphasized">
|
|
11
|
+
<div class="pagination-links__button">
|
|
12
|
+
{{ prev: <ChevronLeftIcon />, next: <ChevronRightIcon /> }[direction]}
|
|
13
|
+
<span>{{ prev: 'Previous', next: 'Next' }[direction]}</span>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<hr class="pagination-links__link__divider" />
|
|
17
|
+
|
|
18
|
+
<article class="pagination-links__page-description">
|
|
19
|
+
<slot name="page-title" />
|
|
20
|
+
<slot name="page-description" />
|
|
21
|
+
</article>
|
|
22
|
+
</a>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
const { href } = Astro.props;
|
|
3
|
+
export interface Props {
|
|
4
|
+
href: string;
|
|
5
|
+
}
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<a href={href} class="pagination-links__link pagination-links__button pagination-links__link--quiet">
|
|
9
|
+
<slot name="icon" />
|
|
10
|
+
<span>
|
|
11
|
+
<slot />
|
|
12
|
+
</span>
|
|
13
|
+
</a>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
2
|
+
import { getCollection } from 'astro:content';
|
|
3
|
+
|
|
4
|
+
export type SidebarEntry = StarlightRouteData['sidebar'][number];
|
|
5
|
+
export type SidebarLink = Extract<SidebarEntry, { type: 'link' }>;
|
|
6
|
+
export type SidebarGroup = Extract<SidebarEntry, { type: 'group' }>;
|
|
7
|
+
|
|
8
|
+
export const flattenSidebar = (sidebar: SidebarEntry[]): SidebarLink[] =>
|
|
9
|
+
sidebar.flatMap((e) => (e.type === 'group' ? flattenSidebar(e.entries) : e));
|
|
10
|
+
|
|
11
|
+
function findParentOfSidebarEntry(sidebar: SidebarEntry[], targetEntry: SidebarEntry): SidebarGroup | null {
|
|
12
|
+
for (const entry of sidebar) {
|
|
13
|
+
if (entry.type === 'group') {
|
|
14
|
+
if (entry.entries.includes(targetEntry)) {
|
|
15
|
+
return entry;
|
|
16
|
+
}
|
|
17
|
+
const foundInChild = findParentOfSidebarEntry(entry.entries, targetEntry);
|
|
18
|
+
if (foundInChild) {
|
|
19
|
+
return foundInChild;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function getPrevNextPage(page: StarlightRouteData, paginationEnabled: boolean) {
|
|
27
|
+
// TODO: respect user `next` / `prev` config from frontmatter the way starlight does
|
|
28
|
+
|
|
29
|
+
if (!paginationEnabled) return null;
|
|
30
|
+
|
|
31
|
+
const docsContent = await getCollection('docs');
|
|
32
|
+
const findSidebarLinkInContent = (link: SidebarLink) =>
|
|
33
|
+
docsContent.find((doc) => {
|
|
34
|
+
if (doc.id === 'index' && link.href === '/') return true;
|
|
35
|
+
return doc.id === link.href.replace(/^\//, '').replace(/\/$/, '');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const currentSidebar = page.sidebar;
|
|
39
|
+
|
|
40
|
+
const paginationSequence: (SidebarLink & { description?: string })[] = flattenSidebar(currentSidebar)
|
|
41
|
+
// Remove injected stl-mobile-only-sidebar-item links - TODO: better solution for this
|
|
42
|
+
.filter((link) => !(link.attrs.class ?? '').trim().split(/\s+/).includes('stl-mobile-only-sidebar-item'))
|
|
43
|
+
// Remove data-stldocs-method links from pagination sequence
|
|
44
|
+
.filter((link) => !link.attrs['data-stldocs-method'])
|
|
45
|
+
// Map data-stldocs-overview=readme links so that their name is not just “Overview”
|
|
46
|
+
.map((link) => {
|
|
47
|
+
if (link.attrs['data-stldocs-overview'] && link.label === 'Overview') {
|
|
48
|
+
const parent = findParentOfSidebarEntry(currentSidebar, link);
|
|
49
|
+
if (parent) return { ...link, label: parent.label };
|
|
50
|
+
}
|
|
51
|
+
return link;
|
|
52
|
+
})
|
|
53
|
+
.map((link) => {
|
|
54
|
+
const contentEntry = findSidebarLinkInContent(link);
|
|
55
|
+
if (contentEntry) return { ...link, description: contentEntry.data.description };
|
|
56
|
+
return link;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const currentIndex = paginationSequence.findIndex((e) => e.isCurrent);
|
|
60
|
+
if (currentIndex === -1) return null;
|
|
61
|
+
|
|
62
|
+
const prevIndex = currentIndex > 0 ? currentIndex - 1 : null;
|
|
63
|
+
const nextIndex = currentIndex < paginationSequence.length - 1 ? currentIndex + 1 : null;
|
|
64
|
+
const prevSidebarEntry = prevIndex !== null ? (paginationSequence[prevIndex] ?? null) : null;
|
|
65
|
+
const nextSidebarEntry = nextIndex !== null ? (paginationSequence[nextIndex] ?? null) : null;
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
prev: prevSidebarEntry,
|
|
69
|
+
next: nextSidebarEntry,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@stainless-api/ui-primitives/scripts';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AstroIntegration } from 'astro';
|
|
2
|
+
import type { StarlightPlugin } from '@astrojs/starlight/types';
|
|
3
|
+
|
|
4
|
+
export const disableCalloutSyntaxAstroIntegration = {
|
|
5
|
+
name: 'stl-starlight-remove-callout-syntax',
|
|
6
|
+
hooks: {
|
|
7
|
+
'astro:config:setup': ({ config: astroConfig }) => {
|
|
8
|
+
// Remove starlight callout syntax in favor of our own callout component
|
|
9
|
+
// updateConfig always deeply merges arrays so we need to mutate remarkPlugins directly
|
|
10
|
+
// in order to remove plugins that starlight added
|
|
11
|
+
astroConfig.markdown.remarkPlugins = astroConfig.markdown.remarkPlugins.filter((plugin, i, arr) => {
|
|
12
|
+
if (typeof plugin !== 'function') return true;
|
|
13
|
+
// remove:
|
|
14
|
+
// 1. remarkDirective plugin
|
|
15
|
+
if (plugin.name === 'remarkDirective') return false;
|
|
16
|
+
// 2. directly followed by remarkAsides plugin (inner function named 'attacher')
|
|
17
|
+
if (plugin.name === 'attacher') {
|
|
18
|
+
const prev = arr[i - 1];
|
|
19
|
+
if (typeof prev === 'function' && prev.name === 'remarkDirective') return false;
|
|
20
|
+
}
|
|
21
|
+
// 3. remarkDirectivesRestoration plugin
|
|
22
|
+
if (plugin.name === 'remarkDirectivesRestoration') return false;
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} satisfies AstroIntegration;
|
|
28
|
+
|
|
29
|
+
export const disableCalloutSyntaxStarlightPlugin = {
|
|
30
|
+
name: 'stl-starlight-remove-callout-syntax',
|
|
31
|
+
hooks: {
|
|
32
|
+
'config:setup': ({ addIntegration }) => {
|
|
33
|
+
addIntegration(disableCalloutSyntaxAstroIntegration);
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
} satisfies StarlightPlugin;
|