@stainless-api/docs 0.1.0-beta.19 → 0.1.0-beta.20
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 +9 -0
- package/components/variables.css +1 -0
- package/locals.d.ts +14 -0
- package/package.json +5 -5
- package/plugin/components/search/SearchIsland.tsx +13 -10
- package/plugin/routes/Docs.astro +1 -2
- package/plugin/routes/Overview.astro +0 -1
- package/src/content.config.ts +9 -0
- package/stl-docs/components/PageTitle.astro +2 -5
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +173 -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/index.ts +1 -0
- package/stl-docs/tabsMiddleware.ts +1 -0
- package/styles/links.css +0 -37
- package/styles/page.css +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @stainless-api/docs
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9cdb24d: Update pagination components, fix search modal
|
|
8
|
+
- Updated dependencies [9cdb24d]
|
|
9
|
+
- @stainless-api/docs-ui@0.1.0-beta.16
|
|
10
|
+
- @stainless-api/ui-primitives@0.1.0-beta.16
|
|
11
|
+
|
|
3
12
|
## 0.1.0-beta.19
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/components/variables.css
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
--stldocs-color-bg: var(--sl-color-bg);
|
|
27
27
|
--stldocs-color-bg-nav: var(--sl-color-bg-nav);
|
|
28
|
+
--stldocs-color-selected: var(--sl-color-gray-6);
|
|
28
29
|
--stldocs-color-bg-ui: var(--sl-color-bg-ui);
|
|
29
30
|
|
|
30
31
|
--stldocs-color-bg-inline-code: var(--sl-color-bg-inline-code);
|
package/locals.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type SidebarEntry = App.Locals['starlightRoute']['sidebar'][number];
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extending Astro’s `App.Locals` interface
|
|
5
|
+
*/
|
|
6
|
+
declare namespace App {
|
|
7
|
+
interface Locals {
|
|
8
|
+
_stlStarlightPage?: {
|
|
9
|
+
skipRenderingStarlightTitle?: boolean;
|
|
10
|
+
hasMarkdownRoute?: boolean;
|
|
11
|
+
fullSidebar?: SidebarEntry[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
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.20",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"remark-gfm": "^4.0.1",
|
|
51
51
|
"remark-stringify": "^11.0.0",
|
|
52
52
|
"unified": "^11.0.5",
|
|
53
|
-
"@stainless-api/
|
|
54
|
-
"@stainless-api/ui
|
|
53
|
+
"@stainless-api/ui-primitives": "0.1.0-beta.16",
|
|
54
|
+
"@stainless-api/docs-ui": "0.1.0-beta.16"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@astrojs/check": "^0.9.5",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"typescript": "5.9.3",
|
|
66
66
|
"vite": "^6.3.6",
|
|
67
67
|
"zod": "^4.0.0",
|
|
68
|
-
"@stainless/
|
|
69
|
-
"@stainless/
|
|
68
|
+
"@stainless/eslint-config": "0.0.0",
|
|
69
|
+
"@stainless/sdk-json": "^0.0.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"vendor-deps": "pnpm tsx scripts/vendor_deps.ts",
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
NavigationProvider,
|
|
15
15
|
SearchProvider,
|
|
16
16
|
} from '@stainless-api/docs-ui/src/contexts';
|
|
17
|
+
import { ComponentProvider } from '@stainless-api/docs-ui/src/contexts/component';
|
|
17
18
|
import type { SearchSettings } from '@stainless-api/docs-ui/src/search/types';
|
|
18
19
|
|
|
19
20
|
let $$highlighter: HighlighterGeneric<BundledLanguage, BundledTheme> | null = null;
|
|
@@ -95,16 +96,18 @@ export function DocsSearch({ settings, currentPath }: { settings: SearchSettings
|
|
|
95
96
|
|
|
96
97
|
return (
|
|
97
98
|
<DocsProvider spec={null} language={language}>
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
<
|
|
101
|
-
<
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
<ComponentProvider>
|
|
100
|
+
<NavigationProvider basePath="/" selectedPath={stainlessPath}>
|
|
101
|
+
<MarkdownProvider {...markdownRenderer}>
|
|
102
|
+
<SearchProvider onSelect={handleSelect} pageFind={pageFind} settings={settings}>
|
|
103
|
+
<div className="stldocs-root">
|
|
104
|
+
<SearchModal id="stldocs-search" />
|
|
105
|
+
{SEARCH?.enableAISearch === true && <ChatModal id="stldocs-chat" />}
|
|
106
|
+
</div>
|
|
107
|
+
</SearchProvider>
|
|
108
|
+
</MarkdownProvider>
|
|
109
|
+
</NavigationProvider>
|
|
110
|
+
</ComponentProvider>
|
|
108
111
|
</DocsProvider>
|
|
109
112
|
);
|
|
110
113
|
}
|
package/plugin/routes/Docs.astro
CHANGED
|
@@ -21,7 +21,6 @@ if (!route) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// PageTitle override will skip rendering the default Starlight title
|
|
24
|
-
// @ts-expect-error - _stlStarlightPage isn't typed yet
|
|
25
24
|
Astro.locals._stlStarlightPage = {
|
|
26
25
|
skipRenderingStarlightTitle: route.props.kind === 'readme' ? false : true,
|
|
27
26
|
};
|
|
@@ -88,7 +87,7 @@ if (readme) {
|
|
|
88
87
|
|
|
89
88
|
.stldocs-snippet-code:not(.stldocs-snippet-response .stldocs-snippet-code) {
|
|
90
89
|
padding: 0 !important;
|
|
91
|
-
|
|
90
|
+
|
|
92
91
|
.astro-code {
|
|
93
92
|
padding: 1rem;
|
|
94
93
|
}
|
|
@@ -14,7 +14,6 @@ const metadata: SpecMetadata = languages
|
|
|
14
14
|
.map<SpecMetadata[number]>((language) => [language, spec.metadata[language]!]);
|
|
15
15
|
|
|
16
16
|
// PageTitle override will skip rendering the default Starlight title
|
|
17
|
-
// @ts-expect-error - _stlStarlightPage isn't typed yet
|
|
18
17
|
Astro.locals._stlStarlightPage = {
|
|
19
18
|
hasMarkdownRoute: false,
|
|
20
19
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Stub here so that `astro sync` generates the correct types for the `docs` content collection
|
|
2
|
+
|
|
3
|
+
import { defineCollection } from 'astro:content';
|
|
4
|
+
import { docsLoader } from '@astrojs/starlight/loaders';
|
|
5
|
+
import { docsSchema } from '@astrojs/starlight/schema';
|
|
6
|
+
|
|
7
|
+
export const collections = {
|
|
8
|
+
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
|
9
|
+
};
|
|
@@ -29,12 +29,9 @@ function sidebarHasEntry(sidebarEntry: StarlightRouteData['sidebar'], currentPat
|
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const skipRenderingStarlightTitle = (Astro.locals._stlStarlightPage?.skipRenderingStarlightTitle ??
|
|
34
|
-
false) as boolean;
|
|
32
|
+
const skipRenderingStarlightTitle = Astro.locals._stlStarlightPage?.skipRenderingStarlightTitle ?? false;
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
const hasMarkdownRoute = (Astro.locals._stlStarlightPage?.hasMarkdownRoute ?? true) as boolean;
|
|
34
|
+
const hasMarkdownRoute = Astro.locals._stlStarlightPage?.hasMarkdownRoute ?? true;
|
|
38
35
|
// ⬆️ hopefully this is temporary. But for now, we don't have a markdown representation of the API reference overview page
|
|
39
36
|
|
|
40
37
|
const currentPath = Astro.url.pathname;
|
|
@@ -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,173 @@
|
|
|
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-ui-muted-background);
|
|
58
|
+
border: 1px solid var(--stl-ui-border);
|
|
59
|
+
border-radius: calc(var(--stl-ui-pagination-border-radius-inner) + var(--stl-ui-pagination-padding));
|
|
60
|
+
|
|
61
|
+
font-size: var(--stl-ui-type-scale-text-sm);
|
|
62
|
+
letter-spacing: normal;
|
|
63
|
+
|
|
64
|
+
display: flex;
|
|
65
|
+
gap: 8px;
|
|
66
|
+
|
|
67
|
+
margin-bottom: 2rem;
|
|
68
|
+
|
|
69
|
+
a {
|
|
70
|
+
border-radius: var(--stl-ui-pagination-border-radius-inner);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.pagination-links__link {
|
|
75
|
+
display: flex;
|
|
76
|
+
border-radius: var(--stl-ui-pagination-border-radius-inner);
|
|
77
|
+
padding: 8px 12px;
|
|
78
|
+
display: flex;
|
|
79
|
+
text-decoration: none;
|
|
80
|
+
align-items: center;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.pagination-links__link--emphasized {
|
|
84
|
+
background-color: var(--stl-ui-background);
|
|
85
|
+
border: 1px solid var(--stl-ui-border);
|
|
86
|
+
flex: 1 1 50%;
|
|
87
|
+
gap: 12px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.pagination-links__link--quiet {
|
|
91
|
+
flex: 0 1 auto;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.pagination-links__button {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
padding: 8px 14px;
|
|
98
|
+
font-weight: 500;
|
|
99
|
+
line-height: 1;
|
|
100
|
+
|
|
101
|
+
svg {
|
|
102
|
+
width: 16px;
|
|
103
|
+
height: 16px;
|
|
104
|
+
margin-block: -4px;
|
|
105
|
+
margin-inline-start: -6px;
|
|
106
|
+
margin-inline-end: 6px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&.pagination-links__link--quiet {
|
|
110
|
+
padding-inline: 22px;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.pagination-links__link__divider {
|
|
115
|
+
border: 0;
|
|
116
|
+
border-inline-start: 1px solid var(--stl-ui-border);
|
|
117
|
+
align-self: stretch;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.pagination-links__page-description {
|
|
121
|
+
padding-block: 4px;
|
|
122
|
+
padding-inline-start: 8px;
|
|
123
|
+
padding-inline-end: 2px;
|
|
124
|
+
line-height: 1.5;
|
|
125
|
+
flex: 1 1 50%;
|
|
126
|
+
width: 0;
|
|
127
|
+
|
|
128
|
+
h2,
|
|
129
|
+
p {
|
|
130
|
+
white-space: nowrap;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
text-overflow: ellipsis;
|
|
133
|
+
}
|
|
134
|
+
h2 {
|
|
135
|
+
font-size: inherit;
|
|
136
|
+
font-weight: 500;
|
|
137
|
+
}
|
|
138
|
+
p {
|
|
139
|
+
font-size: var(--stl-ui-type-scale-text-xs);
|
|
140
|
+
color: var(--stl-ui-foreground-muted);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.pagination-links__link--quiet:hover {
|
|
145
|
+
background-color: rgb(from var(--stl-ui-foreground) r g b / 0.05);
|
|
146
|
+
}
|
|
147
|
+
.pagination-links__link--emphasized:hover {
|
|
148
|
+
border-color: var(--stl-ui-border-emphasis);
|
|
149
|
+
.pagination-links__page-description h2 {
|
|
150
|
+
text-decoration: underline;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* “next” link runs the opposite direction of the “previous” link */
|
|
155
|
+
.pagination-links__link:last-child {
|
|
156
|
+
flex-direction: row-reverse;
|
|
157
|
+
|
|
158
|
+
&.pagination-links__button,
|
|
159
|
+
.pagination-links__button {
|
|
160
|
+
flex-direction: row-reverse;
|
|
161
|
+
svg {
|
|
162
|
+
margin-inline-start: 6px;
|
|
163
|
+
margin-inline-end: -6px;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.pagination-links__page-description {
|
|
168
|
+
padding-inline-start: 2px;
|
|
169
|
+
padding-inline-end: 8px;
|
|
170
|
+
text-align: right;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
</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
|
+
}
|
package/stl-docs/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ function stainlessDocsStarlightIntegration(config: NormalizedStainlessDocsConfig
|
|
|
54
54
|
ContentPanel: resolveSrcFile(COMPONENTS_FOLDER, './content-panel/ContentPanel.astro'),
|
|
55
55
|
TableOfContents: resolveSrcFile(COMPONENTS_FOLDER, './TableOfContents.astro'),
|
|
56
56
|
PageTitle: resolveSrcFile(COMPONENTS_FOLDER, './PageTitle.astro'),
|
|
57
|
+
Pagination: resolveSrcFile(COMPONENTS_FOLDER, './pagination/Pagination.astro'),
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
const plugins: StarlightPlugin[] = [
|
|
@@ -186,5 +186,6 @@ export const onRequest = defineRouteMiddleware(async (context) => {
|
|
|
186
186
|
|
|
187
187
|
matchingGroup?.entries.unshift(...mobileLinks);
|
|
188
188
|
|
|
189
|
+
(context.locals._stlStarlightPage ??= {}).fullSidebar = context.locals.starlightRoute.sidebar;
|
|
189
190
|
context.locals.starlightRoute.sidebar = matchingGroup.entries;
|
|
190
191
|
});
|
package/styles/links.css
CHANGED
|
@@ -10,40 +10,3 @@
|
|
|
10
10
|
border: 1px solid var(--sl-color-accent-high);
|
|
11
11
|
background-color: var(--sl-color-accent-low);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
.pagination-links {
|
|
15
|
-
margin-bottom: 2rem;
|
|
16
|
-
|
|
17
|
-
> a {
|
|
18
|
-
border-radius: var(--sl-button-border-radius);
|
|
19
|
-
border: 1px solid transparent;
|
|
20
|
-
box-shadow: none;
|
|
21
|
-
max-width: 90%;
|
|
22
|
-
text-decoration: none;
|
|
23
|
-
|
|
24
|
-
svg {
|
|
25
|
-
margin-top: 0;
|
|
26
|
-
transform: translateY(6px);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
> a:hover {
|
|
31
|
-
transition: 0.3s;
|
|
32
|
-
border: 1px solid var(--sl-color-accent-high);
|
|
33
|
-
background-color: var(--sl-color-accent-low);
|
|
34
|
-
box-shadow: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* if only one pagination direction */
|
|
38
|
-
> a:first-child:nth-last-child(1) {
|
|
39
|
-
max-width: 45%;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
> a[rel='next'] {
|
|
43
|
-
margin-left: auto;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
> a[rel='prev'] {
|
|
47
|
-
margin-right: auto;
|
|
48
|
-
}
|
|
49
|
-
}
|
package/styles/page.css
CHANGED
|
@@ -91,3 +91,16 @@
|
|
|
91
91
|
--sl-mobile-toc-height: 0rem;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
+
|
|
95
|
+
.content-panel footer {
|
|
96
|
+
/* Don’t render empty footer meta, which results in extra margin getting applied on behalf of the flex gap.
|
|
97
|
+
* Instead, move its margin to its parent. */
|
|
98
|
+
margin-top: 3rem;
|
|
99
|
+
.meta {
|
|
100
|
+
margin-top: 0;
|
|
101
|
+
&:empty,
|
|
102
|
+
&:not(:has(> *)) {
|
|
103
|
+
display: none;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|