@writedocs/generator 0.13.4 → 0.14.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 (89) hide show
  1. package/README.md +28 -28
  2. package/astro.config.mjs +645 -645
  3. package/bin/writedocs.js +359 -356
  4. package/package.json +99 -99
  5. package/src/cli/base-path-layout.js +44 -44
  6. package/src/cli/build-auth.js +135 -135
  7. package/src/cli/build.js +223 -203
  8. package/src/cli/check-built-styles.js +41 -41
  9. package/src/cli/convert.js +124 -124
  10. package/src/cli/dev.js +269 -268
  11. package/src/cli/exit-when-flushed.js +42 -42
  12. package/src/cli/generate-api-pages.js +509 -507
  13. package/src/cli/og-image-worker.js +20 -20
  14. package/src/cli/og-images.js +70 -70
  15. package/src/cli/page-list-watch.js +71 -69
  16. package/src/cli/run-astro.js +97 -97
  17. package/src/cli/run-pagefind.js +154 -154
  18. package/src/cli/write-mcp-files.js +103 -103
  19. package/src/cli/write-redirects-file.js +158 -158
  20. package/src/components/ApiReferencePanel.astro +1792 -1792
  21. package/src/components/AppIcon.astro +51 -51
  22. package/src/components/Card.astro +193 -193
  23. package/src/components/CodeGroup.astro +63 -39
  24. package/src/components/CopyPageMenu.astro +374 -374
  25. package/src/components/Hint.astro +188 -188
  26. package/src/components/Icon.astro +72 -72
  27. package/src/components/Image.astro +165 -165
  28. package/src/components/Tile.astro +67 -67
  29. package/src/components/Video.astro +137 -137
  30. package/src/content.config.ts +219 -203
  31. package/src/layout/BaseLayout.astro +908 -908
  32. package/src/layout/components/AnalyticsScripts.astro +49 -49
  33. package/src/layout/components/Breadcrumbs.astro +98 -98
  34. package/src/layout/components/ConsentBanner.astro +119 -119
  35. package/src/layout/components/MobileMenu.astro +225 -225
  36. package/src/layout/components/NavTree.astro +422 -408
  37. package/src/layout/components/Sidebar.astro +232 -232
  38. package/src/layout/components/SiteFooter.astro +87 -87
  39. package/src/layout/components/TopBar.astro +386 -386
  40. package/src/layout/styles/base.css +332 -326
  41. package/src/layout/styles/mobile-menu.css +285 -285
  42. package/src/lib/agent-markdown.js +164 -164
  43. package/src/lib/asset-dimensions.js +89 -89
  44. package/src/lib/base-path.js +90 -90
  45. package/src/lib/cli-report.js +22 -22
  46. package/src/lib/code-line-numbers.js +13 -0
  47. package/src/lib/config-schema.js +12 -1
  48. package/src/lib/config-schema.ts +2523 -2509
  49. package/src/lib/config.ts +1331 -1316
  50. package/src/lib/consent.js +108 -108
  51. package/src/lib/content-check.js +4 -1
  52. package/src/lib/content-store-reload-integration.js +101 -101
  53. package/src/lib/drafts.js +186 -0
  54. package/src/lib/icon-data-dev.js +53 -53
  55. package/src/lib/image-size.js +152 -152
  56. package/src/lib/json-schema-descriptions.js +228 -228
  57. package/src/lib/link-check.js +553 -544
  58. package/src/lib/llms-index.ts +90 -90
  59. package/src/lib/mcp-dev-integration.js +65 -65
  60. package/src/lib/mcp-index.ts +102 -102
  61. package/src/lib/mintlify-convert.js +605 -605
  62. package/src/lib/moved-api-pages.js +49 -49
  63. package/src/lib/og-cards.js +33 -33
  64. package/src/lib/og-image.js +235 -235
  65. package/src/lib/openapi-dev-status.js +80 -80
  66. package/src/lib/openapi-reload-integration.js +193 -193
  67. package/src/lib/pages.js +346 -312
  68. package/src/lib/project-files-integration.js +116 -116
  69. package/src/lib/project-files.js +137 -137
  70. package/src/lib/rehype-base-path.js +62 -62
  71. package/src/lib/rehype-image-loading.js +71 -71
  72. package/src/lib/robots-txt.js +21 -21
  73. package/src/lib/search-scope.js +44 -44
  74. package/src/lib/selector-placement.js +50 -50
  75. package/src/lib/seo-tags.js +157 -155
  76. package/src/lib/shiki-code-block.js +7 -1
  77. package/src/lib/site-base.ts +27 -27
  78. package/src/lib/styles-asset-integration.js +291 -291
  79. package/src/lib/wdignore-cases.json +195 -195
  80. package/src/lib/wdignore.js +177 -177
  81. package/src/pages/404.astro +63 -63
  82. package/src/pages/[...slug].astro +1773 -1608
  83. package/src/pages/[...slug].md.ts +93 -93
  84. package/src/pages/llms-full.txt.ts +88 -88
  85. package/src/pages/og/[...slug].png.ts +63 -63
  86. package/src/scripts/mobile-menu.ts +80 -80
  87. package/src/scripts/search.ts +245 -245
  88. package/src/scripts/sidebar-scroll.ts +61 -61
  89. package/src/styles/global.css +40 -40
@@ -1,1608 +1,1773 @@
1
- ---
2
- import { getCollection, render, type CollectionEntry } from "astro:content";
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import {
6
- loadDocsConfig,
7
- resolveSections,
8
- resolveGlobalDropdowns,
9
- findSectionIndexForSlug,
10
- buildNavTree,
11
- ancestorGroupsForSlug,
12
- buildSelectors,
13
- buildGlobalDropdowns,
14
- fileIdForEntry,
15
- normalizeEntryId,
16
- flattenNav,
17
- firstSlugOfNavigation,
18
- mergeSeo,
19
- contextMenuOptions,
20
- resolveSiteUrl,
21
- findAllPages,
22
- resolveLandings,
23
- landingSelectors,
24
- } from "../lib/config";
25
- import { writedocsTempDir } from "../lib/writedocs-temp-dir.js";
26
- import { throwIfOpenApiProblem } from "../lib/openapi-dev-status.js";
27
- import { parseOpenApiRef } from "../lib/openapi-ref.js";
28
- import { languageAlternates } from "../lib/item-pages.js";
29
- import { wantsGeneratedCard, ogImagePath } from "../lib/og-image.js";
30
- import BaseLayout from "../layout/BaseLayout.astro";
31
- import Sidebar from "../layout/components/Sidebar.astro";
32
- import TableOfContents from "../layout/components/TableOfContents.astro";
33
- import Breadcrumbs from "../layout/components/Breadcrumbs.astro";
34
- import CopyPageMenu from "../components/CopyPageMenu.astro";
35
- import Callout from "../components/Callout.astro";
36
- import Note from "../components/Note.astro";
37
- import Info from "../components/Info.astro";
38
- import Tip from "../components/Tip.astro";
39
- import Warning from "../components/Warning.astro";
40
- import Danger from "../components/Danger.astro";
41
- import Card from "../components/Card.astro";
42
- import CardGroup from "../components/CardGroup.astro";
43
- import Tabs from "../components/Tabs.astro";
44
- import Tab from "../components/Tab.astro";
45
- import CodeGroup from "../components/CodeGroup.astro";
46
- import Accordion from "../components/Accordion.astro";
47
- import AccordionGroup from "../components/AccordionGroup.astro";
48
- import Steps from "../components/Steps.astro";
49
- import Step from "../components/Step.astro";
50
- import Hint from "../components/Hint.astro";
51
- import Image from "../components/Image.astro";
52
- import Frame from "../components/Frame.astro";
53
- import Video from "../components/Video.astro";
54
- import Parameter from "../components/Parameter.astro";
55
- import Expandable from "../components/Expandable.astro";
56
- import Searchbar from "../components/Searchbar.astro";
57
- import Badge from "../components/Badge.astro";
58
- import Icon from "../components/Icon.astro";
59
- import RequestExample from "../components/RequestExample.astro";
60
- import ResponseExample from "../components/ResponseExample.astro";
61
- import Check from "../components/Check.astro";
62
- import ParamField from "../components/ParamField.astro";
63
- import ResponseField from "../components/ResponseField.astro";
64
- import Columns from "../components/Columns.astro";
65
- import Column from "../components/Column.astro";
66
- import CodeBlock from "../components/CodeBlock.astro";
67
- import Tooltip from "../components/Tooltip.astro";
68
- import Update from "../components/Update.astro";
69
- import Tile from "../components/Tile.astro";
70
- import Panel from "../components/Panel.astro";
71
- import Prompt from "../components/Prompt.astro";
72
- import View from "../components/View.astro";
73
- import Visibility from "../components/Visibility.astro";
74
- import { Tree, FileTree, Color, GitHub } from "../components/compound";
75
- import ApiPlayground from "../components/ApiPlayground.astro";
76
- import ApiReferencePanel from "../components/ApiReferencePanel.astro";
77
- import { searchScope, sectionTrail, ALL_SCOPES } from "../lib/search-scope.js";
78
- import { selectorPlacements } from "../lib/selector-placement.js";
79
- import { spaceOf } from "../lib/hidden-sections.js";
80
- import { navigationPageOrder } from "../lib/pages.js";
81
- import { folderRedirects } from "../lib/folder-redirects.js";
82
- import { oncePerBuild } from "../lib/build-memo.js";
83
- // writedocs.json's `basePath` - the addresses below stay site addresses
84
- // ("/guides/a/"); the base goes in where one is written (lib/site-base.ts).
85
- import { siteHref } from "../lib/site-base";
86
-
87
- // A page is hand-written (the `pages` collection, sourced from anywhere
88
- // in the project - docs/ has no special status, see findAllPages() in
89
- // lib/config.ts) or an auto-generated OpenAPI stub (the `generatedDocs`
90
- // collection, sourced from writedocsTempDir()'s generated-docs/
91
- // directory - see content.config.ts / generate-api-pages.js) - kept as two separate
92
- // collections rather than one, since Astro's loader API has no supported
93
- // way to point a single collection's glob() at more than one base
94
- // directory without one's own cleanup pass deleting the other's entries
95
- // (see content.config.ts's own comment on this). Both share the exact
96
- // same schema, so every consumer below just treats them as one combined
97
- // list.
98
- //
99
- // The two `getCollection()` calls below are inlined at each of their two
100
- // call sites (getStaticPaths, and the component body further down)
101
- // rather than factored into one shared top-level helper: Astro's
102
- // getStaticPaths extraction (a separate bundling pass from the rest of
103
- // the component - see the pathDescription comment further down for
104
- // another instance of this) was observed to silently drop a top-level
105
- // function declaration referenced from inside getStaticPaths, producing
106
- // a raw "getAllDocsEntries is not defined" ReferenceError at build time
107
- // instead of ever running. Keeping both call sites self-contained avoids
108
- // relying on whatever static-analysis pass decides what counts as
109
- // "used" by the extracted chunk.
110
- //
111
- // Each site also only calls getCollection('generatedDocs') when there's
112
- // actually something in it (most sites have no OpenAPI groups - see
113
- // generate-api-pages.js), rather than unconditionally calling it and
114
- // letting content.config.ts's skipIfMissing() loader no-op internally:
115
- // astro:content's own getCollection() logs "The collection ... does not
116
- // exist or is empty" to the console whenever a collection ends up with
117
- // zero registered entries, regardless of *why* it's empty - the data
118
- // store has no supported way to mark a collection as "intentionally
119
- // empty" short of writing at least one entry to it. Not calling
120
- // getCollection() at all for an empty one sidesteps that warning at the
121
- // source instead of trying to suppress it after the fact.
122
- type DocsEntry = CollectionEntry<"pages"> | CollectionEntry<"generatedDocs">;
123
-
124
- export async function getStaticPaths() {
125
- const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
126
- const packageRoot = process.env.WRITEDOCS_PACKAGE_ROOT || process.cwd();
127
- const config = loadDocsConfig(contentDir);
128
- const sections = resolveSections(config.navigation);
129
- const hasGeneratedDocs = fs.existsSync(path.join(writedocsTempDir(contentDir), "generated-docs"));
130
- const hasPages = findAllPages(contentDir).length > 0;
131
- const [pagesEntries, generatedDocsEntries] = await Promise.all([
132
- hasPages ? getCollection("pages") : Promise.resolve([]),
133
- hasGeneratedDocs ? getCollection("generatedDocs") : Promise.resolve([]),
134
- ]);
135
- const entries: DocsEntry[] = [...pagesEntries, ...generatedDocsEntries];
136
- // writedocs.json always references a page by its file id; `entry.id` is
137
- // Astro's own resolved slug for it (the file-path default, or a
138
- // frontmatter `slug` override it recognizes natively - see
139
- // fileIdForEntry() in lib/config.ts) and is what the page is actually
140
- // routed at. Keyed by file id so every navEntry.slug below finds its
141
- // entry regardless of which one is in play.
142
- const entryByFileId = new Map(entries.map((e) => [fileIdForEntry(contentDir, packageRoot, e), e]));
143
-
144
- // "/" is only produced below when some page's *resolved* slug
145
- // (entry.id) is literally "index" - the conventional home page (an
146
- // index.mdx at the project root; a root-level index.mdx keeps file id
147
- // "index" verbatim, since Astro's own default id computation only
148
- // strips a trailing `/index` *segment*, which a single-segment root
149
- // file doesn't have - see fileIdForEntry()'s own comment on this in
150
- // lib/config.ts), or any page overriding its own slug to "index"/"/".
151
- // Most navigations don't have such a page - Astro then warns "no
152
- // matching static path was found for /" on every request. Rather than
153
- // requiring every writedocs.json to name a page "index", synthesize a
154
- // redirect-only route for "/" pointing at the site's first real page
155
- // whenever nothing already claims root.
156
- // Checked against every entry, not just nav-referenced ones - a hidden
157
- // page (see hiddenRoutes below) sitting at "index" claims root exactly
158
- // as well as a nav-listed one would, and needs to suppress the synthetic
159
- // redirect below the same way (two routes both wanting `params.slug:
160
- // undefined` is a build error, not a silent pick-one).
161
- const rootAlreadyClaimed = entries.some((e) => normalizeEntryId(e.id) === "index");
162
- const firstSlug = rootAlreadyClaimed ? null : firstSlugOfNavigation(config.navigation);
163
- const firstEntry = firstSlug ? entryByFileId.get(firstSlug) : undefined;
164
- // Not calling the top-level hrefForSlug() here: it's only otherwise
165
- // referenced from the component body, not from inside getStaticPaths,
166
- // and per the describeSectionPath lesson above, closures introduced
167
- // into getStaticPaths should be self-contained rather than assume a
168
- // module-level binding survives Astro's bundling extraction. firstEntry
169
- // can never resolve to "index" here (that's exactly what
170
- // rootAlreadyClaimed rules out), so the ternary below always resolves
171
- // to the non-root branch.
172
- const rootRedirect = firstEntry
173
- ? [{ params: { slug: undefined }, props: { redirectTo: `/${normalizeEntryId(firstEntry.id)}/`, temporary: true } }]
174
- : [];
175
-
176
- // Tracks every file id a nav-driven route below already claims, so
177
- // hiddenRoutes (further down) knows which entries are left over - any
178
- // page/generatedDocs entry that exists (findAllPages() already required
179
- // it to have frontmatter with a `title` - see content.config.ts's
180
- // docsSchema) but isn't reachable by walking writedocs.json's navigation at
181
- // all. Those still get routed here, just without a nav-derived
182
- // prev/next or section - a page doesn't have to be in the sidebar to be
183
- // a real, directly-linkable page (an in-progress draft, an unlisted
184
- // landing page, etc.).
185
- const claimedFileIds = new Set<string>();
186
-
187
- const pageRoutes = sections.flatMap((section, sectionIndex) => {
188
- const flatNav = flattenNav(section.pages);
189
- // Prev/next skip pages that aren't in the sidebar (frontmatter
190
- // `hidden`) or aren't pages at all (frontmatter `url`, an external
191
- // link) - the reader should land on the next page they could also
192
- // have clicked in the sidebar. Inlined for the same reason as the
193
- // error branch below.
194
- const isPaginationStop = (slug: string) => {
195
- const data = entryByFileId.get(slug)?.data;
196
- return Boolean(data) && !data!.hidden && !data!.url;
197
- };
198
- return flatNav.map((navEntry, i) => {
199
- const entry = entryByFileId.get(navEntry.slug);
200
- if (!entry) {
201
- // Inlined rather than a separate top-level helper: Astro's
202
- // getStaticPaths extraction (a separate bundling pass from the
203
- // rest of the component) was observed to silently drop a
204
- // top-level function declaration that's only referenced inside
205
- // this rarely-taken branch, producing a raw "X is not defined"
206
- // ReferenceError instead of this readable message. Keeping the
207
- // logic inside getStaticPaths' own closure avoids relying on
208
- // whatever static-analysis pass decides what counts as "used".
209
- const pathDescription =
210
- section.path.length === 0
211
- ? "(root)"
212
- : section.path
213
- .map((seg) => {
214
- const item = seg.items[seg.index] as Record<string, unknown>;
215
- const name = (item.tab ?? item.version ?? item.language ?? item.dropdown ?? item.product) as string;
216
- return `${seg.kind} "${name}"`;
217
- })
218
- .join(" > ");
219
- throw new Error(
220
- `[writedocs] writedocs.json references page "${navEntry.slug}"` +
221
- ` (${pathDescription})` +
222
- ` but no matching file was found`,
223
- );
224
- }
225
- claimedFileIds.add(navEntry.slug);
226
- const prev = flatNav.slice(0, i).findLast((e) => isPaginationStop(e.slug)) ?? null;
227
- const next = flatNav.slice(i + 1).find((e) => isPaginationStop(e.slug)) ?? null;
228
- const urlSlug = normalizeEntryId(entry.id);
229
- // A frontmatter `url` page (Mintlify's external link) exists only
230
- // to put that link in the sidebar - its own URL redirects there.
231
- if (entry.data.url) {
232
- return {
233
- params: { slug: urlSlug === "index" ? undefined : urlSlug },
234
- props: { redirectTo: entry.data.url },
235
- };
236
- }
237
- return {
238
- params: { slug: urlSlug === "index" ? undefined : urlSlug },
239
- props: { entry, prev, next, sectionIndex },
240
- };
241
- });
242
- });
243
-
244
- // An item's own page (a tab's, a dropdown's, ... `page` - resolveLandings()
245
- // in lib/config.ts) that no sidebar lists: shown inside its item. One the
246
- // sidebar does list was routed above, in its sidebar. Its Next is the
247
- // item's first sidebar page, if the item has a sidebar of its own.
248
- const landings = resolveLandings(config.navigation);
249
- const landingRoutes = landings.flatMap((landing, landingIndex) => {
250
- if (claimedFileIds.has(landing.slug)) return [];
251
- const entry = entryByFileId.get(landing.slug);
252
- if (!entry) {
253
- const last = landing.path[landing.path.length - 1];
254
- const item = landing.item as Record<string, unknown>;
255
- const name = (item.tab ?? item.version ?? item.language ?? item.dropdown ?? item.product) as string;
256
- throw new Error(
257
- `[writedocs] writedocs.json's ${last.kind} "${name}" names page "${landing.slug}" as its own page,` +
258
- ` but no matching file was found`,
259
- );
260
- }
261
- claimedFileIds.add(landing.slug);
262
- const next =
263
- flattenNav(landing.pages).find((e) => {
264
- const data = entryByFileId.get(e.slug)?.data;
265
- return Boolean(data) && !data!.hidden && !data!.url;
266
- }) ?? null;
267
- const urlSlug = normalizeEntryId(entry.id);
268
- if (entry.data.url) {
269
- return [{ params: { slug: urlSlug === "index" ? undefined : urlSlug }, props: { redirectTo: entry.data.url } }];
270
- }
271
- return [{ params: { slug: urlSlug === "index" ? undefined : urlSlug }, props: { entry, prev: null, next, landingIndex } }];
272
- });
273
-
274
- // "Hidden" pages: any file the `pages`/`generatedDocs` collections
275
- // picked up that writedocs.json's navigation never references (see
276
- // claimedFileIds above) still gets a real route here - just with no
277
- // prev/next (nothing in nav to derive that from) and no section of its
278
- // own to be "active" in. findSectionIndexForSlug's existing "0 if this
279
- // slug isn't in any section" fallback (already used nowhere else in
280
- // this file, but built for exactly this) picks which section's
281
- // sidebar/selectors a hidden page borrows - arbitrary, but no worse
282
- // than the alternative of hidden pages having no chrome at all.
283
- const hiddenRoutes = entries
284
- .filter((entry) => !claimedFileIds.has(fileIdForEntry(contentDir, packageRoot, entry)))
285
- .map((entry) => {
286
- const urlSlug = normalizeEntryId(entry.id);
287
- return {
288
- params: { slug: urlSlug === "index" ? undefined : urlSlug },
289
- props: {
290
- entry,
291
- prev: null,
292
- next: null,
293
- sectionIndex: findSectionIndexForSlug(sections, fileIdForEntry(contentDir, packageRoot, entry)),
294
- isHidden: true,
295
- },
296
- };
297
- });
298
-
299
- // Folder addresses with pages under them but none of their own
300
- // (`/docs/creator/`) redirect to the first page under them
301
- // (lib/folder-redirects.js). Preferred in the reader's order: navigation
302
- // order, public sections before hidden ones, pages outside the
303
- // navigation last.
304
- const slugOf = (route: { params: { slug?: string } }) => route.params.slug ?? "index";
305
- const inHiddenSection = sections.map((section) => spaceOf(section.path) !== null);
306
- const contentRoutes = pageRoutes.filter((route) => !("redirectTo" in route.props));
307
- // An item's own page counts where the navigation names it: before the
308
- // item's sidebar (navigationPageOrder()), so `/guides/` opens the Guides
309
- // tab's own page rather than its first sidebar page.
310
- type ContentRoute = { params: { slug?: string }; props: { entry?: DocsEntry; sectionIndex?: number; landingIndex?: number } };
311
- const navOrder = new Map(navigationPageOrder(config.navigation).map((id, i) => [id, i]));
312
- const orderOf = (route: ContentRoute) => navOrder.get(fileIdForEntry(contentDir, packageRoot, route.props.entry!)) ?? Infinity;
313
- const inHiddenItem = (route: ContentRoute) =>
314
- route.props.landingIndex !== undefined
315
- ? spaceOf(landings[route.props.landingIndex].path) !== null
316
- : inHiddenSection[route.props.sectionIndex!];
317
- const navContent = [...contentRoutes, ...landingRoutes.filter((route) => !("redirectTo" in route.props))] as ContentRoute[];
318
- const folderTargets = [
319
- ...navContent.filter((route) => !inHiddenItem(route)).sort((a, b) => orderOf(a) - orderOf(b)).map(slugOf),
320
- ...navContent.filter(inHiddenItem).sort((a, b) => orderOf(a) - orderOf(b)).map(slugOf),
321
- ...hiddenRoutes.map(slugOf),
322
- ];
323
- const takenAddresses = new Set([
324
- ...[...pageRoutes, ...landingRoutes, ...hiddenRoutes].map(slugOf),
325
- ...(config.redirects ?? []).map((r) => r.source.replace(/^\/+|\/+$/g, "")),
326
- ]);
327
- const folderRoutes = [...folderRedirects(folderTargets, takenAddresses)].map(([folder, target]) => ({
328
- params: { slug: folder },
329
- props: { redirectTo: `/${target}/`, temporary: true },
330
- }));
331
-
332
- return [...rootRedirect, ...pageRoutes, ...landingRoutes, ...hiddenRoutes, ...folderRoutes];
333
- }
334
-
335
- interface Props {
336
- redirectTo?: string;
337
- // The automatic "/" and folder redirects: temporary, see below.
338
- temporary?: boolean;
339
- entry?: DocsEntry;
340
- prev?: { slug: string; group: string | null } | null;
341
- next?: { slug: string; group: string | null } | null;
342
- sectionIndex?: number;
343
- // Set by hiddenRoutes in getStaticPaths above - a page with no place in
344
- // writedocs.json's navigation has no sidebar section of its own to show, so
345
- // its default mode drops the sidebar entirely (see pageMode below)
346
- // rather than borrowing findSectionIndexForSlug's arbitrary fallback
347
- // section's sidebar contents, which would misleadingly suggest the page
348
- // belongs there.
349
- isHidden?: boolean;
350
- // Set by landingRoutes in getStaticPaths above - an item's own page that
351
- // no sidebar lists, shown inside that item (index into resolveLandings()).
352
- landingIndex?: number;
353
- }
354
-
355
- const rawProps = Astro.props as Props;
356
- if (rawProps.redirectTo) {
357
- // The automatic "/" redirect is temporary (302): its target is just the
358
- // navigation's first page, and it goes away once the site has a page at
359
- // "/". A 301 is remembered by the browser for good - after that, "/" kept
360
- // redirecting even with a home page in place, in `writedocs dev` (every
361
- // project's preview shares localhost:4321) and for returning visitors.
362
- // A frontmatter `url` page stays 301. In a static build the status only
363
- // picks the refresh delay of Astro's redirect page, and the build rewrites
364
- // those pages to redirect at once either way (rewrite-redirect-pages.js).
365
- return Astro.redirect(siteHref(rawProps.redirectTo), rawProps.temporary ? 302 : 301);
366
- }
367
- const {
368
- entry,
369
- prev = null,
370
- next = null,
371
- sectionIndex = 0,
372
- isHidden = false,
373
- landingIndex,
374
- } = rawProps as Required<Props>;
375
-
376
- const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
377
- const packageRoot = process.env.WRITEDOCS_PACKAGE_ROOT || process.cwd();
378
- // `writedocs dev`, with an OpenAPI spec that stopped parsing: the error
379
- // instead of the page, until it parses again (lib/openapi-dev-status.js).
380
- throwIfOpenApiProblem(contentDir);
381
- const config = loadDocsConfig(contentDir);
382
- // Once per build, like the lookup tables further down.
383
- const sections = oncePerBuild("slug:sections", () => resolveSections(config.navigation));
384
- // Falls back to an empty stand-in section rather than crashing on
385
- // `.pages` below - only reachable for a hidden page (see hiddenRoutes in
386
- // getStaticPaths above) on a site whose writedocs.json has no navigation
387
- // sections at all, which previously could never produce a route to
388
- // render in the first place.
389
- // An item's own page shown inside its item (landingRoutes above): the item's
390
- // path, and its own sidebar if it has one.
391
- const landing = landingIndex === undefined ? undefined : oncePerBuild("slug:landings", () => resolveLandings(config.navigation))[landingIndex];
392
- const activeSection = landing ? { pages: landing.pages, path: landing.path } : sections[sectionIndex] ?? { pages: [], path: [] };
393
-
394
- const { Content, headings } = await render(entry);
395
- const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3);
396
-
397
- // The lookup tables below are the same for every page, so a build makes
398
- // them once (oncePerBuild(), lib/build-memo.js) - findAllPages() alone reads
399
- // every page file of the project, and ran here once per page. In
400
- // `writedocs dev` they're made again on every request, as before.
401
- const { titleByFileId, navTitleByFileId, entryByFileId, methodByFileId } = await oncePerBuild("slug:lookups", async () => {
402
- const hasGeneratedDocs = fs.existsSync(path.join(writedocsTempDir(contentDir), "generated-docs"));
403
- const hasPages = findAllPages(contentDir).length > 0;
404
- const [pagesEntries, generatedDocsEntries] = await Promise.all([
405
- hasPages ? getCollection("pages") : Promise.resolve([]),
406
- hasGeneratedDocs ? getCollection("generatedDocs") : Promise.resolve([]),
407
- ]);
408
- const entries: DocsEntry[] = [...pagesEntries, ...generatedDocsEntries];
409
- // Two maps keyed by file id (not `entry.id` - see fileIdForEntry() in
410
- // lib/config.ts for why those can differ once a page overrides its own
411
- // slug): titles for prev/next and sidebar labels, and the entries
412
- // themselves so hrefForSlug can resolve a writedocs.json file-id reference to
413
- // wherever that page actually got routed.
414
- const titleByFileId = new Map<string, string>();
415
- // Navigation labels (sidebar, topbar dropdowns): a page's `sidebarTitle`
416
- // when it has one - Mintlify's short nav label - else its `title`.
417
- const navTitleByFileId = new Map<string, string>();
418
- const entryByFileId = new Map<string, DocsEntry>();
419
- // The HTTP method badge NavTree.astro shows next to an API operation
420
- // page in the sidebar - read straight off the page's own `openapi:
421
- // "METHOD /path"` frontmatter rather than the resolved operation JSON,
422
- // since the method itself is right there in that string already and
423
- // doesn't need a spec lookup.
424
- const methodByFileId = new Map<string, string>();
425
- for (const e of entries) {
426
- const fileId = fileIdForEntry(contentDir, packageRoot, e);
427
- titleByFileId.set(fileId, e.data.title);
428
- navTitleByFileId.set(fileId, e.data.sidebarTitle ?? e.data.title);
429
- entryByFileId.set(fileId, e);
430
- // `hideApiMarker` (Mintlify's) drops the badge for this one page.
431
- const apiRef = parseOpenApiRef(e.data.openapi);
432
- if (apiRef && !e.data.hideApiMarker) {
433
- methodByFileId.set(fileId, apiRef.method);
434
- }
435
- }
436
- return { titleByFileId, navTitleByFileId, entryByFileId, methodByFileId };
437
- });
438
- const titleForSlug = (slug: string) => titleByFileId.get(slug) ?? slug;
439
- const navTitleForSlug = (slug: string) => navTitleByFileId.get(slug) ?? slug;
440
- const methodForSlug = (slug: string) => methodByFileId.get(slug) ?? null;
441
- // Frontmatter that changes how a page appears in navigation (hidden, url,
442
- // icon, tag, deprecated) - see buildNavTree() in lib/config.ts.
443
- const navMetaForSlug = (slug: string) => entryByFileId.get(slug)?.data;
444
- const hrefForSlug = (slug: string) => {
445
- const raw = entryByFileId.get(slug)?.id ?? slug;
446
- const effective = normalizeEntryId(raw);
447
- return effective === "index" ? "/" : `/${effective}/`;
448
- };
449
- // The current page's own file id (as writedocs.json references it) - distinct
450
- // from `entry.id` (its resolved URL slug) for the same reason as above,
451
- // and what every "is this the active page" comparison below needs, since
452
- // navTree/globalDropdowns are built from writedocs.json's file-id space.
453
- const currentFileId = fileIdForEntry(contentDir, packageRoot, entry);
454
- // A section's tree doesn't depend on which of its pages is open (NavTree.astro
455
- // marks the current one), so it's built once per section in a build.
456
- const navTree = oncePerBuild(`slug:nav:${landingIndex === undefined ? `s${sectionIndex}` : `l${landingIndex}`}`, () => buildNavTree(activeSection.pages, navTitleForSlug, methodForSlug, navMetaForSlug));
457
- // The ancestor sidebar-group trail above the auto <h1> (Breadcrumbs.astro)
458
- // - empty for a page sitting at the top level of its Section with no
459
- // enclosing group, in which case [...slug].astro below skips rendering
460
- // the component entirely rather than showing a breadcrumb bar with
461
- // nothing in it but the page's own title.
462
- const breadcrumbs = ancestorGroupsForSlug(navTree, currentFileId, hrefForSlug);
463
-
464
- // The reader's page's own position within the active Section's flattened
465
- // pages list - passed to buildSelectors() so a version/language switch
466
- // can try to land on the *same* page in the target option instead of
467
- // always its first page (equivalentPageIn() in lib/config.ts). -1 (not
468
- // found) just disables that - firstSlugOf() is still the fallback.
469
- const activePagePosition = flattenNav(activeSection.pages).findIndex((e) => e.slug === currentFileId);
470
-
471
- // One selector per level of the active page's navigation path (tabs,
472
- // versions, languages, products, or a dropdown nested partway down),
473
- // plus the always-visible global dropdown list - see BaseLayout.astro
474
- // for how each renders.
475
- // An item's own page also gets the level under the item, with nothing chosen.
476
- const selectors = landing ? landingSelectors(landing, hrefForSlug) : buildSelectors(activeSection.path, hrefForSlug, activePagePosition);
477
- // <html lang>: the `language` of the navigation level this page sits under,
478
- // if any. A hidden page has no level of its own (activeSection is only a
479
- // fallback for its chrome), so it keeps the default.
480
- // For search: the section line under this page's result (and words it can
481
- // be found by), and the version/language/product it belongs to - search
482
- // shows the reader's own first. A hidden page belongs to no section.
483
- const pageSearchScope = isHidden ? { key: ALL_SCOPES, label: "" } : searchScope(activeSection.path);
484
- const pageSectionTrail = isHidden ? "" : sectionTrail(activeSection.path, breadcrumbs);
485
- // A page under a hidden navigation item searches its own index, not the
486
- // site's (lib/hidden-sections.js, cli/run-pagefind.js).
487
- const pageSearchSpace = isHidden ? null : spaceOf(activeSection.path);
488
- const languageSegment = isHidden ? undefined : activeSection.path.find((segment) => segment.kind === "language");
489
- const pageLang = languageSegment ? (languageSegment.items[languageSegment.index] as { language: string }).language : undefined;
490
- const globalDropdowns = buildGlobalDropdowns(
491
- resolveGlobalDropdowns(config.navigation),
492
- currentFileId,
493
- navTitleForSlug,
494
- hrefForSlug,
495
- navMetaForSlug,
496
- );
497
-
498
- // Meta tags: this page's own frontmatter `seo` overrides writedocs.json's
499
- // site-wide `seo` field by field (mergeSeo() in lib/config.ts), and the
500
- // canonical/OG/Twitter URLs need this page's actual served path - reusing
501
- // hrefForSlug (already built above for prev/next and the sidebar) rather
502
- // than recomputing it, since it already encodes the same
503
- // frontmatter-slug-override-aware routing logic.
504
- const pageSeo = mergeSeo(config.seo, entry.data.seo);
505
- // A page with no picture of its own for link previews gets the generated
506
- // card (lib/og-image.js, served by src/pages/og/[...slug].png.ts).
507
- if (wantsGeneratedCard(pageSeo, entry.data, config.seo)) pageSeo.ogImage = ogImagePath(normalizeEntryId(entry.id));
508
- const currentPath = hrefForSlug(currentFileId);
509
- // This page in each language, for hreflang (languageAlternates() in
510
- // lib/item-pages.js) - a hidden page belongs to no language level.
511
- const alternates = isHidden
512
- ? []
513
- : languageAlternates(activeSection.path, currentFileId, activeSection.pages, landing !== undefined).map((a) => ({
514
- lang: a.lang,
515
- href: hrefForSlug(a.slug),
516
- }));
517
- // The trail for the page's structured data (lib/json-ld.js): home, the
518
- // groups above the page that have a page of their own, the page.
519
- const structuredTrail = [
520
- { name: config.name, href: "/" },
521
- ...breadcrumbs.filter((crumb) => crumb.href).map((crumb) => ({ name: crumb.label, href: crumb.href as string })),
522
- ...(currentPath === "/" ? [] : [{ name: entry.data.title, href: currentPath }]),
523
- ];
524
-
525
- // Page mode (content.config.ts's docsSchema `mode` field, defaulted to
526
- // 'default' there so this is never actually undefined) - see
527
- // BaseLayout.astro for what each value strips out of the topbar/shell,
528
- // and the comment on <BaseLayout mode=...> below for what this file
529
- // itself controls (which slots get filled at all, and how the article
530
- // itself renders).
531
- // A hidden page (isHidden - see hiddenRoutes/Props above) defaults to
532
- // "frame" instead of "default": it has no real section of its own, so
533
- // the sidebar would otherwise show findSectionIndexForSlug's arbitrary
534
- // fallback section with nothing in it actually active - "frame" drops
535
- // the sidebar (and ToC) while keeping the topbar and normal article
536
- // styling. Only a *default*: a hidden page's own frontmatter mode, if
537
- // it set one explicitly, still wins.
538
- // An item's own page with nothing for a sidebar - the item holds tabs, or
539
- // versions, ... that switch elsewhere - is laid out the same way.
540
- const landingWithoutSidebar =
541
- landing !== undefined &&
542
- flattenNav(landing.pages).length === 0 &&
543
- !selectorPlacements(selectors, { sidebar: true }).includes("sidebar");
544
- const pageMode = (isHidden || landingWithoutSidebar) && entry.data.mode === "default" ? "frame" : entry.data.mode;
545
- const showSidebar = pageMode === "default" || pageMode === "wide";
546
- // Products inside a tab or dropdown switch at the top of the sidebar, not in
547
- // the top bar (lib/selector-placement.js - TopBar.astro applies the same rule).
548
- const sidebarPlacements = selectorPlacements(selectors, { sidebar: showSidebar });
549
- const sidebarSwitchers = selectors.filter((_, i) => sidebarPlacements[i] === "sidebar");
550
- const showToc = pageMode === "default";
551
- // 'custom' and 'blank' both get the bare wd-canvas treatment below (no
552
- // auto <h1>, no prev/next, no prose width/padding) - they only differ in
553
- // whether BaseLayout keeps the topbar, which is BaseLayout's own concern
554
- // (mode is passed straight through), not something this file needs to
555
- // branch on separately.
556
- const isCanvasMode = pageMode === "custom" || pageMode === "blank";
557
-
558
- // The "Copy page" menu (CopyPageMenu.astro) - on by default, with the
559
- // options writedocs.json's `contextMenu` leaves on (contextMenuOptions() in
560
- // lib/config-schema.ts; `false` turns it off), and only
561
- // shown where there's a real auto-rendered <h1> to sit next to: canvas
562
- // mode pages (custom/blank) have no such header (a hand-built landing
563
- // page controls its own layout, there's nothing standard to anchor the
564
- // menu to), and OpenAPI operation pages render almost entirely from the
565
- // spec rather than prose - see [...slug].md.ts's own comment on why
566
- // those are excluded from the .md route this menu links to in the first
567
- // place, which this mirrors on the UI side.
568
- const contextMenuItems = contextMenuOptions(config.contextMenu, { mcp: config.mcp });
569
- const showCopyPageMenu = contextMenuItems.length > 0 && !isCanvasMode;
570
- const siteUrl = resolveSiteUrl(config);
571
-
572
- const components = {
573
- Callout,
574
- Note,
575
- Info,
576
- Tip,
577
- Warning,
578
- Danger,
579
- Card,
580
- CardGroup,
581
- Tabs,
582
- Tab,
583
- CodeGroup,
584
- Accordion,
585
- AccordionGroup,
586
- Steps,
587
- Step,
588
- Hint,
589
- Image,
590
- Frame,
591
- Video,
592
- Parameter,
593
- Expandable,
594
- Searchbar,
595
- Badge,
596
- Icon,
597
- RequestExample,
598
- ResponseExample,
599
- Check,
600
- ParamField,
601
- ResponseField,
602
- Columns,
603
- Column,
604
- CodeBlock,
605
- Tooltip,
606
- Update,
607
- Tile,
608
- Panel,
609
- Prompt,
610
- View,
611
- Visibility,
612
- Tree,
613
- FileTree,
614
- Color,
615
- GitHub,
616
- };
617
- ---
618
-
619
- <BaseLayout
620
- config={config}
621
- title={entry.data.title}
622
- description={entry.data.description}
623
- path={currentPath}
624
- seo={pageSeo}
625
- selectors={selectors}
626
- globalDropdowns={globalDropdowns}
627
- mode={pageMode}
628
- lang={pageLang}
629
- alternates={alternates}
630
- breadcrumbs={structuredTrail}
631
- isApi={Boolean(entry.data.openapi)}
632
- >
633
- {showSidebar && <Sidebar slot="sidebar" navTree={navTree} hrefForSlug={hrefForSlug} currentSlug={currentFileId} switchers={sidebarSwitchers} />}
634
- {
635
- isCanvasMode ? (
636
- // 'custom' and 'blank' both get this treatment: no auto <h1>, no
637
- // prev/next nav, none of .wd-article's own prose max-width/padding -
638
- // just the page's own MDX/component content, edge to edge. Still gets
639
- // a data-pagefind-body wrapper so a hand-built page's own text is
640
- // still searchable.
641
- <div class="wd-canvas" data-pagefind-body>
642
- <Content components={components} />
643
- {entry.data.openapi && <ApiPlayground operation={entry.data.openapi} contentDir={contentDir} />}
644
- {/* After the content: a result's excerpt shows the section only when
645
- that's what matched. */}
646
- <div hidden data-markdown-ignore data-wd-search-scope={pageSearchScope.key} data-wd-search-scope-label={pageSearchScope.label} data-wd-search-space={pageSearchSpace?.id} data-wd-search-public={pageSearchSpace?.searchPublic ? "true" : undefined} data-pagefind-filter={`scope:${pageSearchScope.key}`}>
647
- {pageSectionTrail && <span data-pagefind-meta="section">{pageSectionTrail}</span>}
648
- </div>
649
- </div>
650
- ) : (
651
- <article class={`wd-article ${pageMode === "wide" ? "wd-article-wide" : ""}`} data-pagefind-body>
652
- {breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} />}
653
- <div class="wd-article-header">
654
- {
655
- // Frontmatter `deprecated` puts a label beside the <h1>, not in
656
- // it - the <h1>'s text is the search index's page title.
657
- entry.data.deprecated ? (
658
- <div class="wd-article-title">
659
- <h1 data-pagefind-meta="title">{entry.data.title}</h1>
660
- <span class="wd-deprecated-badge">Deprecated</span>
661
- </div>
662
- ) : (
663
- <h1 data-pagefind-meta="title">{entry.data.title}</h1>
664
- )
665
- }
666
- {showCopyPageMenu && (
667
- <CopyPageMenu currentPath={currentPath} siteUrl={siteUrl} siteName={config.name} options={contextMenuItems} />
668
- )}
669
- </div>
670
- <Content components={components} />
671
- {entry.data.openapi && <ApiPlayground operation={entry.data.openapi} contentDir={contentDir} />}
672
- <div hidden data-markdown-ignore data-wd-search-scope={pageSearchScope.key} data-wd-search-scope-label={pageSearchScope.label} data-wd-search-space={pageSearchSpace?.id} data-wd-search-public={pageSearchSpace?.searchPublic ? "true" : undefined} data-pagefind-filter={`scope:${pageSearchScope.key}`}>
673
- {pageSectionTrail && <span data-pagefind-meta="section">{pageSectionTrail}</span>}
674
- </div>
675
- {!entry.data.hideFooterPagination && (
676
- <nav class="wd-prevnext" data-pagefind-ignore data-markdown-ignore>
677
- {prev && (
678
- <a class="wd-prevnext-card wd-prevnext-prev" href={siteHref(hrefForSlug(prev.slug))}>
679
- <span class="wd-prevnext-row">
680
- <svg
681
- class="wd-prevnext-icon"
682
- width="16"
683
- height="16"
684
- viewBox="0 0 24 24"
685
- fill="none"
686
- stroke="currentColor"
687
- stroke-width="2"
688
- stroke-linecap="round"
689
- stroke-linejoin="round"
690
- aria-hidden="true"
691
- >
692
- <line x1="19" y1="12" x2="5" y2="12" />
693
- <polyline points="12 19 5 12 12 5" />
694
- </svg>
695
- <span class="wd-prevnext-label">Previous</span>
696
- </span>
697
- <span class="wd-prevnext-title">{titleForSlug(prev.slug)}</span>
698
- </a>
699
- )}
700
- {next && (
701
- <a class="wd-prevnext-card wd-prevnext-next" href={siteHref(hrefForSlug(next.slug))}>
702
- <span class="wd-prevnext-row">
703
- <span class="wd-prevnext-label">Next</span>
704
- <svg
705
- class="wd-prevnext-icon"
706
- width="16"
707
- height="16"
708
- viewBox="0 0 24 24"
709
- fill="none"
710
- stroke="currentColor"
711
- stroke-width="2"
712
- stroke-linecap="round"
713
- stroke-linejoin="round"
714
- aria-hidden="true"
715
- >
716
- <line x1="5" y1="12" x2="19" y2="12" />
717
- <polyline points="12 5 19 12 12 19" />
718
- </svg>
719
- </span>
720
- <span class="wd-prevnext-title">{titleForSlug(next.slug)}</span>
721
- </a>
722
- )}
723
- </nav>
724
- )}
725
- </article>
726
- )
727
- }
728
- {
729
- showToc &&
730
- (entry.data.openapi ? (
731
- <ApiReferencePanel slot="toc" operation={entry.data.openapi} contentDir={contentDir} />
732
- ) : (
733
- <TableOfContents slot="toc" headings={tocHeadings} />
734
- ))
735
- }
736
- </BaseLayout>
737
-
738
- <script>
739
- import { mcpServerUrl, cursorInstallLink, vscodeInstallLink } from "../lib/mcp-links.js";
740
- // writedocs.json's `basePath` ("" or "/docs", astro.config.mjs) - the MCP
741
- // server is at the site's root, under it. Written as `__WD_BASE__ ? ... : ...`
742
- // so a site without one gets the same code as before basePath existed.
743
- declare const __WD_BASE__: string;
744
-
745
- // Astro assigns every h2-h4 an id automatically, but doesn't add a
746
- // clickable anchor next to it. rehype-autolink-headings can't be used
747
- // for this directly: Astro's own heading-id rehype plugin always runs
748
- // AFTER any user-supplied rehypePlugins in its pipeline, so a plugin
749
- // that links existing ids never sees them. Adding the anchor client-side
750
- // sidesteps that ordering constraint entirely.
751
- function addHeadingAnchors(root: ParentNode) {
752
- root
753
- .querySelectorAll<HTMLElement>(".wd-article > h2[id], .wd-article > h3[id], .wd-article > h4[id]")
754
- .forEach((heading) => {
755
- if (heading.querySelector(".wd-heading-anchor")) return;
756
- const anchor = document.createElement("a");
757
- anchor.className = "wd-heading-anchor";
758
- anchor.href = `#${heading.id}`;
759
- anchor.setAttribute("aria-label", "Link to this section");
760
- anchor.textContent = "#";
761
- heading.appendChild(anchor);
762
- });
763
- }
764
- addHeadingAnchors(document);
765
- document.addEventListener("astro:page-load", () => addHeadingAnchors(document));
766
-
767
- // Copy-to-clipboard button for every fenced (```) code block - the
768
- // button itself is emitted at build time by codeBlockTransformer
769
- // (astro.config.mjs / src/lib/shiki-code-block.js), wrapping each
770
- // <pre> in a .wd-code-block container; this just wires up the click
771
- // behavior client-side, same dataset-guarded init pattern as
772
- // addHeadingAnchors above.
773
- function initCodeCopyButtons(root: ParentNode) {
774
- root.querySelectorAll<HTMLButtonElement>(".wd-code-copy-btn").forEach((btn) => {
775
- if (btn.dataset.wdInit) return;
776
- btn.dataset.wdInit = "true";
777
- btn.addEventListener("click", async () => {
778
- const pre = btn.closest(".wd-code-block")?.querySelector("pre");
779
- if (!pre) return;
780
- try {
781
- await navigator.clipboard.writeText(pre.textContent ?? "");
782
- } catch {
783
- return; // clipboard unavailable (e.g. insecure context) - fail silently
784
- }
785
- btn.textContent = "✓";
786
- btn.classList.add("wd-code-copied");
787
- window.setTimeout(() => {
788
- btn.textContent = "⧉";
789
- btn.classList.remove("wd-code-copied");
790
- }, 1500);
791
- });
792
- });
793
- }
794
- initCodeCopyButtons(document);
795
- document.addEventListener("astro:page-load", () => initCodeCopyButtons(document));
796
-
797
- // Clipboard-copy button for CopyPageMenu.astro's primary "Copy page"
798
- // button (the split button's left half - the right half is just a
799
- // .wd-dropdown-trigger caret, handled by BaseLayout's own
800
- // initDropdowns()) - same dataset-guarded init pattern as
801
- // initCodeCopyButtons above, but fetches its content from the button's
802
- // own data-md-path (the [...slug].md.ts route for the current page -
803
- // see CopyPageMenu.astro) rather than reading it from an
804
- // already-rendered element on the page, since the raw Markdown source
805
- // isn't otherwise present in the DOM anywhere (the rendered HTML
806
- // content is not the same text).
807
- function initCopyPageMenu(root: ParentNode) {
808
- root.querySelectorAll<HTMLButtonElement>("button[data-copy-page]").forEach((btn) => {
809
- if (btn.dataset.wdInit) return;
810
- btn.dataset.wdInit = "true";
811
- const label = btn.querySelector<HTMLElement>(".wd-copy-page-primary-label");
812
- const originalLabel = label?.textContent ?? "Copy page";
813
- btn.addEventListener("click", async () => {
814
- const mdPath = btn.dataset.mdPath;
815
- if (!mdPath) return;
816
- try {
817
- const res = await fetch(mdPath);
818
- const text = await res.text();
819
- await navigator.clipboard.writeText(text);
820
- } catch {
821
- return; // fetch/clipboard unavailable - fail silently, same as initCodeCopyButtons
822
- }
823
- btn.classList.add("wd-copy-page-copied");
824
- if (label) label.textContent = "Copied!";
825
- window.setTimeout(() => {
826
- btn.classList.remove("wd-copy-page-copied");
827
- if (label) label.textContent = originalLabel;
828
- }, 1500);
829
- });
830
- });
831
- }
832
- initCopyPageMenu(document);
833
- document.addEventListener("astro:page-load", () => initCopyPageMenu(document));
834
-
835
- // "Open in ChatGPT/Claude/Perplexity" on a site with no writedocs.json
836
- // `domain`: the page's absolute .md URL isn't known at build time, so the
837
- // link is completed here from the address the page is served from (see
838
- // CopyPageMenu.astro) - same prompt the build writes when it does know.
839
- function initAskLinks(root: ParentNode) {
840
- root.querySelectorAll<HTMLAnchorElement>("a[data-ask-base][data-md-path]").forEach((link) => {
841
- const url = new URL(link.dataset.mdPath ?? "/", window.location.origin).href;
842
- link.href = link.dataset.askBase + encodeURIComponent(`Read ${url} so you can answer questions about it.`);
843
- });
844
- }
845
- initAskLinks(document);
846
- document.addEventListener("astro:page-load", () => initAskLinks(document));
847
-
848
- // The menu's MCP options (CopyPageMenu.astro). "Copy MCP server URL"
849
- // copies it and says so in its own label - inside the menu, which stays
850
- // open to show it. "Connect to Cursor / VS Code" on a site with no
851
- // `domain` get their install links here, for the address the page is
852
- // served from.
853
- function initMcpMenu(root: ParentNode) {
854
- const serverUrl = (el: HTMLElement) => el.dataset.copyMcp || mcpServerUrl(__WD_BASE__ ? window.location.origin + __WD_BASE__ : window.location.origin);
855
- root.querySelectorAll<HTMLButtonElement>("button[data-copy-mcp]").forEach((btn) => {
856
- if (btn.dataset.wdInit) return;
857
- btn.dataset.wdInit = "true";
858
- const label = btn.querySelector<HTMLElement>(".wd-copy-page-item-title, .wd-copy-page-primary-label");
859
- const originalLabel = label?.textContent ?? "";
860
- btn.addEventListener("click", async (e) => {
861
- e.stopPropagation();
862
- try {
863
- await navigator.clipboard.writeText(serverUrl(btn));
864
- } catch {
865
- return;
866
- }
867
- if (label) label.textContent = "Copied!";
868
- window.setTimeout(() => {
869
- if (label) label.textContent = originalLabel;
870
- }, 1500);
871
- });
872
- });
873
- root.querySelectorAll<HTMLAnchorElement>("a[data-mcp-install]").forEach((link) => {
874
- const url = mcpServerUrl(__WD_BASE__ ? window.location.origin + __WD_BASE__ : window.location.origin);
875
- const name = link.dataset.mcpName ?? document.title;
876
- link.href = link.dataset.mcpInstall === "cursor" ? cursorInstallLink(name, url) : vscodeInstallLink(name, url);
877
- });
878
- }
879
- initMcpMenu(document);
880
- document.addEventListener("astro:page-load", () => initMcpMenu(document));
881
-
882
- // Show more/less toggle for ```js expandable code blocks - same
883
- // build-time-emitted-button + client-wired-click pattern as the copy
884
- // button above; codeBlockTransformer only adds this button when the
885
- // fence's meta string contains the `expandable` keyword.
886
- function initCodeExpandButtons(root: ParentNode) {
887
- root.querySelectorAll<HTMLButtonElement>(".wd-code-expand-btn").forEach((btn) => {
888
- if (btn.dataset.wdInit) return;
889
- btn.dataset.wdInit = "true";
890
- btn.addEventListener("click", () => {
891
- const block = btn.closest(".wd-code-expandable");
892
- if (!block) return;
893
- const expanded = block.classList.toggle("wd-code-expanded");
894
- btn.textContent = expanded ? "Show less" : "Show more";
895
- });
896
- });
897
- }
898
- initCodeExpandButtons(document);
899
- document.addEventListener("astro:page-load", () => initCodeExpandButtons(document));
900
-
901
- // Renders ```mermaid fenced blocks - already reshaped at build time into
902
- // plain <div class="mermaid">source text</div> containers (see
903
- // rehypeMermaid in astro.config.mjs/src/lib/mermaid-rehype.js) - into
904
- // actual SVG diagrams. Lazily imports the mermaid package itself, same
905
- // reasoning as initSearch's Pagefind import above: most pages have no
906
- // diagrams at all, no reason to ship/parse that bundle on every load.
907
- let mermaidLoadPromise: Promise<typeof import("mermaid")> | null = null;
908
- function ensureMermaid() {
909
- if (!mermaidLoadPromise) mermaidLoadPromise = import("mermaid");
910
- return mermaidLoadPromise;
911
- }
912
-
913
- // mermaid.run() replaces a block's contents with the rendered SVG,
914
- // destroying the original diagram source - stashed in a data attribute
915
- // the first time a block is seen (before it's ever rendered), so a
916
- // later re-render (see the wd:theme-change listener below - diagrams
917
- // are baked to static SVG at render time, so a theme change needs an
918
- // actual re-render, unlike Shiki code blocks which swap colors live via
919
- // CSS custom properties) has something to restore from.
920
- function stashMermaidSource(root: ParentNode) {
921
- root.querySelectorAll<HTMLElement>(".mermaid").forEach((el) => {
922
- if (el.dataset.mermaidSource === undefined) el.dataset.mermaidSource = el.textContent ?? "";
923
- });
924
- }
925
-
926
- async function renderMermaid(root: ParentNode, theme: "light" | "dark") {
927
- const blocks = Array.from(root.querySelectorAll<HTMLElement>(".mermaid"));
928
- if (blocks.length === 0) return;
929
- const { default: mermaid } = await ensureMermaid();
930
- mermaid.initialize({ startOnLoad: false, theme: theme === "dark" ? "dark" : "default", securityLevel: "strict" });
931
- blocks.forEach((el) => {
932
- el.removeAttribute("data-processed"); // mermaid's own re-render guard - see run()'s docs
933
- el.innerHTML = el.dataset.mermaidSource ?? "";
934
- });
935
- // suppressErrors: a malformed diagram on one block shouldn't take
936
- // down every other diagram on the page - mermaid still renders a
937
- // per-block error SVG in place and logs details to the console.
938
- await mermaid.run({ nodes: blocks, suppressErrors: true });
939
- }
940
-
941
- function initMermaid(root: ParentNode) {
942
- stashMermaidSource(root);
943
- if (!root.querySelector(".mermaid")) return;
944
- const theme = document.documentElement.dataset.theme === "dark" ? "dark" : "light";
945
- renderMermaid(root, theme);
946
- }
947
- initMermaid(document);
948
- document.addEventListener("astro:page-load", () => initMermaid(document));
949
- document.addEventListener("wd:theme-change", ((e: CustomEvent<{ theme: "light" | "dark" }>) => {
950
- renderMermaid(document, e.detail.theme);
951
- }) as EventListener);
952
-
953
- // RequestExample/ResponseExample.astro's own docking behavior - on
954
- // desktop, moves their rendered .wd-example-panel(s) out of the normal
955
- // article flow and into .wd-toc-col (replacing whatever it would
956
- // otherwise show - the heading-based TableOfContents or
957
- // ApiReferencePanel, per those two components' own comment), matching
958
- // Mintlify's stated behavior for the components this was modeled on:
959
- // pinned in the sidebar on desktop, plain in-place code blocks below
960
- // 1150px (the exact breakpoint .wd-toc-col itself disappears at - see
961
- // base.css). This can't be done at build time: MDX compiles a page's
962
- // whole body into one content flow, with no way for a static render to
963
- // place part of that flow into a *different* column's own slot output
964
- // - a client-side move after the fact is the only way to get this
965
- // content into a sibling column's subtree at all.
966
- function initExamplePanels(root: ParentNode) {
967
- const tocCol = document.querySelector<HTMLElement>(".wd-toc-col");
968
- if (!tocCol) return; // no toc column on this page (mode !== 'default') - nothing to dock into
969
-
970
- // Top-level panels only: Mintlify's <Panel> (Panel.astro) is itself a
971
- // .wd-example-panel, and a RequestExample/ResponseExample inside it
972
- // moves with it rather than on its own.
973
- const panels = Array.from(root.querySelectorAll<HTMLElement>(".wd-example-panel")).filter(
974
- (panel) => !panel.parentElement?.closest(".wd-example-panel"),
975
- );
976
- if (panels.length === 0) return;
977
- if (tocCol.dataset.wdExampleInit) return;
978
- tocCol.dataset.wdExampleInit = "true";
979
-
980
- // Response always docks below Request regardless of source order,
981
- // matching Mintlify's own stated behavior for these two components.
982
- panels.sort((a, b) => {
983
- const rank = (el: HTMLElement) => (el.classList.contains("wd-request-example") ? 0 : 1);
984
- return rank(a) - rank(b);
985
- });
986
-
987
- // A comment node marks each panel's original in-flow position, so
988
- // undock() (a desktop -> mobile resize, or simply no matching media
989
- // query at all) can put it back exactly where the article's own
990
- // content expects it, rather than leaving a permanent gap.
991
- const anchors = panels.map((panel) => {
992
- const anchor = document.createComment("wd-example-anchor");
993
- panel.before(anchor);
994
- return anchor;
995
- });
996
-
997
- let host = tocCol.querySelector<HTMLElement>(".wd-example-host");
998
- if (!host) {
999
- host = document.createElement("div");
1000
- host.className = "wd-example-host";
1001
- tocCol.prepend(host);
1002
- }
1003
- const dockedHost = host;
1004
-
1005
- // Whatever .wd-toc-col would otherwise render (TableOfContents' own
1006
- // <nav class="wd-toc">, or ApiReferencePanel's own markup) - hidden
1007
- // while panels are docked rather than removed, so undock() has
1008
- // something to restore instead of needing to re-render it.
1009
- const existingTocContent = Array.from(tocCol.children).filter((el) => el !== dockedHost) as HTMLElement[];
1010
-
1011
- function dock() {
1012
- existingTocContent.forEach((el) => (el.style.display = "none"));
1013
- dockedHost.hidden = false;
1014
- panels.forEach((panel) => dockedHost.appendChild(panel));
1015
- }
1016
- function undock() {
1017
- dockedHost.hidden = true;
1018
- existingTocContent.forEach((el) => (el.style.display = ""));
1019
- panels.forEach((panel, i) => anchors[i].after(panel));
1020
- }
1021
- const desktopQuery = window.matchMedia("(min-width: 1151px)");
1022
- const sync = () => (desktopQuery.matches ? dock() : undock());
1023
- sync();
1024
- desktopQuery.addEventListener("change", sync);
1025
- }
1026
- initExamplePanels(document);
1027
- document.addEventListener("astro:page-load", () => initExamplePanels(document));
1028
- </script>
1029
-
1030
- <style>
1031
- .wd-article {
1032
- max-width: 900px;
1033
- margin: 0 auto;
1034
- /* Top padding matches Sidebar.astro's .wd-sidebar and
1035
- TableOfContents.astro's .wd-toc exactly (both 1.5rem) - all three
1036
- are siblings in the same .wd-shell row with no padding of their
1037
- own on .wd-main-col in between, so this is what actually lines up
1038
- the article's top edge with the sidebar/TOC's first item instead
1039
- of starting visibly lower than both. */
1040
- padding: 1.5rem 1.5rem 4rem;
1041
- }
1042
- /* frontmatter `mode: wide` - the table of contents column is gone (see
1043
- BaseLayout.astro), so the article itself gets more room too, rather
1044
- than just recentering the same 760px column into now-empty space. */
1045
- .wd-article-wide {
1046
- max-width: 1040px;
1047
- }
1048
- /* frontmatter `mode: custom` - no prose width/padding at all, no
1049
- max-width, no centering: a hand-built landing page controls its own
1050
- layout completely, full-bleed if it wants to. */
1051
- .wd-canvas {
1052
- width: 100%;
1053
- }
1054
- /* Wraps the auto-rendered <h1> together with CopyPageMenu (only
1055
- rendered when writedocs.json's `contextMenu` isn't off - see
1056
- showCopyPageMenu above) so the two sit on one row, menu pinned to
1057
- the right. Always present (even with no menu) rather than only
1058
- wrapping the <h1> conditionally, so the <h1>'s own top/bottom
1059
- spacing comes from exactly one place regardless of whether the menu
1060
- renders - flex items don't margin-collapse with their container the
1061
- way a bare <h1> would with .wd-article, so that margin is
1062
- reset/reapplied here instead of relying on the browser's default
1063
- heading margin still doing the right thing once it's no longer a
1064
- direct .wd-article child. */
1065
- .wd-article-header {
1066
- display: flex;
1067
- flex-wrap: wrap;
1068
- align-items: center;
1069
- justify-content: space-between;
1070
- gap: 0.75rem 1rem;
1071
- margin: 0 0 1rem;
1072
- }
1073
- .wd-article-header h1 {
1074
- margin: 0;
1075
- /* A word longer than the whole line (a long product name on a phone)
1076
- breaks rather than pushing the page wider than the screen. */
1077
- overflow-wrap: break-word;
1078
- }
1079
- /* The title takes the room the menu leaves. Its basis is 0, so the row
1080
- only wraps when its longest word and the menu can't share a line - on
1081
- a desktop, a long title still wraps beside the menu; on a phone, a long
1082
- word sends the menu below the title instead of off the screen. */
1083
- .wd-article-header > h1,
1084
- .wd-article-header > .wd-article-title {
1085
- flex: 1 1 0;
1086
- }
1087
- /* Frontmatter `deprecated: true` (Mintlify's) - same amber as the
1088
- sidebar's own deprecated tag (NavTree.astro) and Parameter's
1089
- deprecated badge. */
1090
- .wd-article-title {
1091
- display: flex;
1092
- align-items: center;
1093
- flex-wrap: wrap;
1094
- gap: 0.6rem;
1095
- }
1096
- .wd-deprecated-badge {
1097
- display: inline-block;
1098
- padding: 0.15rem 0.55rem;
1099
- border-radius: 999px;
1100
- font-size: 0.8rem;
1101
- font-weight: 700;
1102
- color: #d97706;
1103
- background: color-mix(in srgb, #d97706 15%, transparent);
1104
- }
1105
- .wd-prevnext {
1106
- display: flex;
1107
- justify-content: space-between;
1108
- margin-top: 3rem;
1109
- padding-top: 1.5rem;
1110
- border-top: 1px solid var(--wd-border);
1111
- gap: 1rem;
1112
- }
1113
- /* Two side-by-side cards, each taking up to half the row - flex: 1 1
1114
- 0 rather than a fixed 50% so a single remaining card (first page:
1115
- only next, last page: only prev) grows to fill the width instead
1116
- of leaving an empty gap next to it. */
1117
- .wd-prevnext-card {
1118
- display: flex;
1119
- flex: 1 1 0;
1120
- min-width: 0;
1121
- flex-direction: column;
1122
- gap: 0.1rem;
1123
- padding: 0.75rem 1.1rem;
1124
- border: 1px solid var(--wd-border);
1125
- border-radius: 0.75rem;
1126
- text-decoration: none;
1127
- color: inherit;
1128
- transition:
1129
- border-color 0.15s ease,
1130
- box-shadow 0.15s ease;
1131
- }
1132
- /* Both cards are identical at rest - the accent border/glow in the
1133
- reference screenshot is that card's :hover state, not a permanent
1134
- treatment on Next, so both wd-prevnext-prev and wd-prevnext-next
1135
- share this one hover rule instead of Next getting its own always-on
1136
- copy. Built from --wd-primary via color-mix() rather than a flat
1137
- hardcoded color, so it stays correct under any theme's own accent. */
1138
- .wd-prevnext-card:hover {
1139
- border-color: var(--wd-primary);
1140
- box-shadow: 0 0 0 3px color-mix(in srgb, var(--wd-primary) 10%, transparent);
1141
- }
1142
- .wd-prevnext-row {
1143
- display: flex;
1144
- align-items: center;
1145
- justify-content: space-between;
1146
- gap: 0.5rem;
1147
- color: var(--wd-text-muted);
1148
- font-size: 0.75rem;
1149
- }
1150
- .wd-prevnext-icon {
1151
- flex-shrink: 0;
1152
- color: var(--wd-text-muted);
1153
- transition: color 0.15s ease;
1154
- }
1155
- .wd-prevnext-title {
1156
- font-weight: 600;
1157
- font-size: 0.85rem;
1158
- color: var(--wd-heading);
1159
- white-space: nowrap;
1160
- overflow: hidden;
1161
- text-overflow: ellipsis;
1162
- transition: color 0.15s ease;
1163
- }
1164
- /* Previous's title sits at the same end of the card its own
1165
- "Previous" label already does (right-aligned, next to the arrow's
1166
- fixed spot on the left) - Next's title stays left-aligned, at the
1167
- same end its own "Next" label sits. Keeps each card's two rows
1168
- reading as one consistent left/right-anchored column instead of
1169
- the title always defaulting to the left regardless of which side
1170
- its card's own label/arrow occupy. */
1171
- .wd-prevnext-prev .wd-prevnext-title {
1172
- text-align: right;
1173
- }
1174
- /* Icon and title pick up the accent color on hover - the
1175
- "Next"/"Previous" label itself stays muted even then, since it's a
1176
- plain UI affordance rather than the actual content being pointed
1177
- to. */
1178
- .wd-prevnext-card:hover .wd-prevnext-icon,
1179
- .wd-prevnext-card:hover .wd-prevnext-title {
1180
- color: var(--wd-primary);
1181
- }
1182
- @media (width <= 640px) {
1183
- .wd-prevnext {
1184
- flex-direction: column;
1185
- }
1186
- }
1187
- </style>
1188
-
1189
- <style is:global>
1190
- /*
1191
- * These target direct children of .wd-article (or, for inline marks,
1192
- * specific prose containers) rather than bare tag selectors. MDX
1193
- * component internals (Card titles/links, prev/next nav links) also
1194
- * live inside .wd-article but nested deeper - a bare ".wd-article h3"
1195
- * or ".wd-article a" would win the specificity tie against those
1196
- * components' own scoped styles and visibly break them (oversized
1197
- * card titles, underlined cards, underlined prev/next links). Real
1198
- * MDX content (headings, paragraphs, lists, etc.) renders as flat
1199
- * direct children of .wd-article, so the ">" combinator is enough to
1200
- * separate "actual content" from "component chrome" without needing
1201
- * per-component :not() exceptions.
1202
- */
1203
- /* --wd-topbar-offset is set by initTopbarOffset() (src/scripts/
1204
- topbar-offset.ts) to the sticky topbar's real measured height - see
1205
- its own file comment for why a fixed 5rem (this var()'s own
1206
- fallback, for the instant before that script's first measurement)
1207
- isn't enough once a site's topbar grows a second row. Without this,
1208
- jumping straight to a #heading link (a hard load, or clicking one of
1209
- the .wd-heading-anchor links below) lands the heading partly hidden
1210
- under the sticky topbar. */
1211
- .wd-article > h2 {
1212
- font-size: 1.5rem;
1213
- margin: 2.75rem 0 1rem;
1214
- padding-top: 0.25rem;
1215
- scroll-margin-top: var(--wd-topbar-offset, 5rem);
1216
- }
1217
- .wd-article > h3 {
1218
- font-size: 1.2rem;
1219
- margin: 2rem 0 0.75rem;
1220
- scroll-margin-top: var(--wd-topbar-offset, 5rem);
1221
- }
1222
- .wd-article > h4 {
1223
- font-size: 1rem;
1224
- margin: 1.5rem 0 0.5rem;
1225
- scroll-margin-top: var(--wd-topbar-offset, 5rem);
1226
- }
1227
- .wd-article > h2:first-child,
1228
- .wd-article > h3:first-child {
1229
- margin-top: 0;
1230
- }
1231
- .wd-article > p {
1232
- margin: 0.9rem 0;
1233
- }
1234
- .wd-article > ul,
1235
- .wd-article > ol {
1236
- margin: 0.9rem 0;
1237
- padding-left: 1.4rem;
1238
- }
1239
- .wd-article li {
1240
- margin: 0.35rem 0;
1241
- }
1242
- .wd-article li > ul,
1243
- .wd-article li > ol {
1244
- margin: 0.35rem 0;
1245
- }
1246
- .wd-article > blockquote {
1247
- margin: 1.25rem 0;
1248
- padding: 0.1rem 1rem;
1249
- border-left: 3px solid var(--wd-primary);
1250
- background: var(--wd-surface);
1251
- border-radius: 0 0.4rem 0.4rem 0;
1252
- color: var(--wd-text-muted);
1253
- }
1254
- .wd-article blockquote p {
1255
- margin: 0.7rem 0;
1256
- }
1257
- .wd-article > table {
1258
- width: 100%;
1259
- border-collapse: collapse;
1260
- margin: 1.25rem 0;
1261
- font-size: 0.9rem;
1262
- }
1263
- .wd-article th,
1264
- .wd-article td {
1265
- text-align: left;
1266
- padding: 0.55rem 0.75rem;
1267
- border-bottom: 1px solid var(--wd-border);
1268
- vertical-align: top;
1269
- }
1270
- .wd-article th {
1271
- color: var(--wd-text-muted);
1272
- font-weight: 600;
1273
- font-size: 0.8rem;
1274
- text-transform: uppercase;
1275
- letter-spacing: 0.03em;
1276
- }
1277
- .wd-article > hr {
1278
- border: none;
1279
- border-top: 1px solid var(--wd-border);
1280
- margin: 2.5rem 0;
1281
- }
1282
- /* Fenced (```) code blocks - codeBlockTransformer
1283
- (src/lib/shiki-code-block.js) wraps every one's <pre> in this
1284
- .wd-code-block div at build time (plus an optional .wd-code-title
1285
- bar, and the copy/expand buttons - see below). The card-like chrome
1286
- (border/radius/background) lives on the wrapper rather than the
1287
- <pre> itself so a title bar, when present, can sit flush above it
1288
- inside the same box; Astro's Shiki pipeline (dual light/dark themes
1289
- configured in astro.config.mjs) already supplies the <pre>'s own
1290
- background/text colors via inline styles. Matches both a standalone
1291
- block (direct child of .wd-article) and one nested inside
1292
- <CodeGroup> (which re-targets the margin/radius itself via its own
1293
- more specific `.wd-codegroup > .wd-code-block` rule in
1294
- CodeGroup.astro). */
1295
- .wd-code-block {
1296
- position: relative;
1297
- margin: 1.25rem 0;
1298
- border: 1px solid var(--wd-border);
1299
- border-radius: 0.55rem;
1300
- overflow: hidden;
1301
- }
1302
- .wd-article pre.astro-code {
1303
- margin: 0;
1304
- padding: 1rem 1.1rem;
1305
- border: none;
1306
- border-radius: 0;
1307
- font-size: 0.85rem;
1308
- line-height: 1.55;
1309
- }
1310
- .wd-code-title {
1311
- padding: 0.5rem 1rem;
1312
- font-family: monospace;
1313
- font-size: 0.78rem;
1314
- font-weight: 500;
1315
- color: var(--wd-text-muted);
1316
- background: var(--wd-surface);
1317
- border-bottom: 1px solid var(--wd-border);
1318
- }
1319
- /* A fence's `icon="..."` (shiki-code-block.js) - the icon's own SVG
1320
- arrives as a data URL in --wd-code-icon and is used as a mask, so it
1321
- paints in the title's text color instead of the SVG's own fill. */
1322
- .wd-code-title-icon {
1323
- display: inline-block;
1324
- width: 1em;
1325
- height: 1em;
1326
- margin-right: 0.45rem;
1327
- vertical-align: -0.125em;
1328
- background: currentColor;
1329
- -webkit-mask: var(--wd-code-icon) center / contain no-repeat;
1330
- mask: var(--wd-code-icon) center / contain no-repeat;
1331
- }
1332
- .wd-code-copy-btn {
1333
- position: absolute;
1334
- top: 0.6rem;
1335
- right: 0.6rem;
1336
- display: inline-flex;
1337
- align-items: center;
1338
- justify-content: center;
1339
- width: 1.85rem;
1340
- height: 1.85rem;
1341
- padding: 0;
1342
- border-radius: 0.4rem;
1343
- border: 1px solid var(--wd-border);
1344
- background: var(--wd-background);
1345
- color: var(--wd-text-muted);
1346
- font-size: 0.9rem;
1347
- line-height: 1;
1348
- cursor: pointer;
1349
- opacity: 0;
1350
- transition:
1351
- opacity 0.15s ease,
1352
- color 0.15s ease,
1353
- background 0.15s ease,
1354
- border-color 0.15s ease;
1355
- }
1356
- .wd-code-block:hover .wd-code-copy-btn,
1357
- .wd-code-copy-btn:focus-visible {
1358
- opacity: 1;
1359
- }
1360
- .wd-code-copy-btn:hover {
1361
- color: var(--wd-text);
1362
- background: var(--wd-surface);
1363
- }
1364
- .wd-code-copy-btn.wd-code-copied {
1365
- opacity: 1;
1366
- color: #16a34a;
1367
- border-color: #16a34a;
1368
- }
1369
- /* ```js wrap - opts a single block into wrapping long lines instead
1370
- of horizontal-scrolling (the default). */
1371
- .wd-code-wrap pre.astro-code,
1372
- .wd-code-wrap pre.astro-code code {
1373
- white-space: pre-wrap;
1374
- word-break: break-word;
1375
- overflow-x: hidden;
1376
- }
1377
- /* ```js lines (or showLineNumbers) - a CSS-counter gutter, no markup
1378
- needed beyond a class since every line is already its own .line
1379
- span. */
1380
- .wd-code-lines pre.astro-code code {
1381
- counter-reset: wd-code-line;
1382
- }
1383
- .wd-code-lines pre.astro-code .line {
1384
- counter-increment: wd-code-line;
1385
- }
1386
- .wd-code-lines pre.astro-code .line::before {
1387
- content: counter(wd-code-line);
1388
- display: inline-block;
1389
- width: 1.8em;
1390
- margin-right: 1em;
1391
- text-align: right;
1392
- color: var(--wd-text-muted);
1393
- user-select: none;
1394
- }
1395
- /* ```js expandable - collapses to a fixed height with a "Show more"
1396
- button below; toggled via .wd-code-expanded, added by the click
1397
- handler in the <script> block below. */
1398
- .wd-code-expandable pre.astro-code {
1399
- max-height: 340px;
1400
- overflow-y: hidden;
1401
- }
1402
- .wd-code-expandable.wd-code-expanded pre.astro-code {
1403
- max-height: none;
1404
- }
1405
- .wd-code-expand-btn {
1406
- display: block;
1407
- width: 100%;
1408
- padding: 0.5rem;
1409
- border: none;
1410
- border-top: 1px solid var(--wd-border);
1411
- background: var(--wd-surface);
1412
- color: var(--wd-primary);
1413
- font-size: 0.8rem;
1414
- font-weight: 500;
1415
- cursor: pointer;
1416
- }
1417
- .wd-code-expand-btn:hover {
1418
- background: color-mix(in srgb, var(--wd-primary) 8%, var(--wd-surface));
1419
- }
1420
- /* Line/word annotation classes added by the official
1421
- @shikijs/transformers transformers configured alongside
1422
- codeBlockTransformer in astro.config.mjs:
1423
- .line.highlighted - transformerMetaHighlight
1424
- (```js {1,3-5}) and
1425
- transformerNotationHighlight
1426
- (// [!code highlight]/[!code hl])
1427
- .line.diff.add / .diff.remove - transformerNotationDiff
1428
- (// [!code ++] / // [!code --])
1429
- .line.error / .warning / .info - transformerNotationErrorLevel
1430
- (// [!code error]/[!code warning])
1431
- (also carries .highlighted)
1432
- pre.has-focused, .line.focused - transformerNotationFocus
1433
- (// [!code focus])
1434
- .highlighted-word - transformerMetaWordHighlight
1435
- (```js /someWord/) and
1436
- transformerNotationWordHighlight
1437
- (// [!code word:someWord])
1438
- Every .line needs display:inline-block + full width for its
1439
- highlight background to stretch edge-to-edge (by default a <span>
1440
- only extends as wide as its own text) - harmless for plain lines,
1441
- since inline-block with no other styling renders identically to
1442
- the browser's normal inline flow here. */
1443
- .astro-code .line {
1444
- display: inline-block;
1445
- width: 100%;
1446
- }
1447
- .astro-code .line.highlighted {
1448
- background: color-mix(in srgb, var(--wd-primary) 12%, transparent);
1449
- margin: 0 -1.1rem;
1450
- padding: 0 1.1rem;
1451
- width: calc(100% + 2.2rem);
1452
- }
1453
- .astro-code .line.diff {
1454
- margin: 0 -1.1rem;
1455
- padding: 0 1.1rem 0 1.6rem;
1456
- width: calc(100% + 2.2rem);
1457
- position: relative;
1458
- }
1459
- .astro-code .line.diff.add {
1460
- background: color-mix(in srgb, #16a34a 15%, transparent);
1461
- }
1462
- .astro-code .line.diff.remove {
1463
- background: color-mix(in srgb, #dc2626 15%, transparent);
1464
- opacity: 0.85;
1465
- }
1466
- .astro-code .line.diff.add::before,
1467
- .astro-code .line.diff.remove::before {
1468
- position: absolute;
1469
- left: 0.5rem;
1470
- font-weight: 700;
1471
- }
1472
- .astro-code .line.diff.add::before {
1473
- content: "+";
1474
- color: #16a34a;
1475
- }
1476
- .astro-code .line.diff.remove::before {
1477
- content: "-";
1478
- color: #dc2626;
1479
- }
1480
- .astro-code .line.error {
1481
- background: color-mix(in srgb, #dc2626 15%, transparent);
1482
- }
1483
- .astro-code .line.warning {
1484
- background: color-mix(in srgb, #d97706 15%, transparent);
1485
- }
1486
- .astro-code .line.info {
1487
- background: color-mix(in srgb, #2563eb 12%, transparent);
1488
- }
1489
- pre.astro-code.has-focused .line {
1490
- opacity: 0.45;
1491
- filter: blur(0.3px);
1492
- transition:
1493
- opacity 0.2s ease,
1494
- filter 0.2s ease;
1495
- }
1496
- pre.astro-code.has-focused .line.focused {
1497
- opacity: 1;
1498
- filter: none;
1499
- }
1500
- pre.astro-code.has-focused:hover .line {
1501
- opacity: 1;
1502
- filter: none;
1503
- }
1504
- .astro-code .highlighted-word {
1505
- background: color-mix(in srgb, var(--wd-primary) 20%, transparent);
1506
- border-radius: 0.25rem;
1507
- padding: 0.05rem 0.2rem;
1508
- margin: -0.05rem -0.15rem;
1509
- }
1510
- .wd-article img {
1511
- max-width: 100%;
1512
- border-radius: 0.5rem;
1513
- border: 1px solid var(--wd-border);
1514
- }
1515
- /* ```mermaid fenced blocks (rehypeMermaid in astro.config.mjs reshapes
1516
- them into this plain <div class="mermaid"> container at build time -
1517
- see mermaid-rehype.js) - mermaid.js (initMermaid() below) replaces
1518
- the raw source text with a rendered <svg> in place, client-side.
1519
- overflow-x: auto rather than shrinking the diagram, since a wide
1520
- flowchart squeezed into the article's ~760px column becomes
1521
- unreadable; centering only kicks in once the svg fits, via the
1522
- inline-block + text-align combo below. */
1523
- .wd-article > div.mermaid {
1524
- margin: 1.25rem 0;
1525
- padding: 1rem;
1526
- overflow-x: auto;
1527
- text-align: center;
1528
- background: var(--wd-surface);
1529
- border: 1px solid var(--wd-border);
1530
- border-radius: 0.55rem;
1531
- }
1532
- .wd-article > div.mermaid svg {
1533
- display: inline-block;
1534
- max-width: 100%;
1535
- }
1536
- /* Only style links inside actual prose containers - excludes Card
1537
- (which is itself an <a>) and the prev/next nav links. */
1538
- .wd-article p a,
1539
- .wd-article li a,
1540
- .wd-article td a,
1541
- .wd-article blockquote a {
1542
- text-decoration: underline;
1543
- text-decoration-color: color-mix(in srgb, var(--wd-primary) 40%, transparent);
1544
- text-underline-offset: 2px;
1545
- }
1546
- .wd-article strong {
1547
- font-weight: 600;
1548
- }
1549
- .wd-article > h2 a[href^="#"],
1550
- .wd-article > h3 a[href^="#"],
1551
- .wd-article > h4 a[href^="#"] {
1552
- text-decoration: none;
1553
- }
1554
- .wd-heading-anchor {
1555
- display: inline-block;
1556
- margin-left: 0.5rem;
1557
- color: var(--wd-text-muted);
1558
- opacity: 0;
1559
- text-decoration: none;
1560
- font-weight: 400;
1561
- transition: opacity 0.1s ease;
1562
- }
1563
- .wd-article > h2:hover .wd-heading-anchor,
1564
- .wd-article > h3:hover .wd-heading-anchor,
1565
- .wd-article > h4:hover .wd-heading-anchor,
1566
- .wd-heading-anchor:focus {
1567
- opacity: 1;
1568
- }
1569
- /* RequestExample/ResponseExample.astro's own panels, and the
1570
- .wd-toc-col host initExamplePanels() (see the <script> above) docks
1571
- them into on desktop - is:global (this whole style block already
1572
- is) since .wd-toc-col itself is BaseLayout.astro's own markup, a
1573
- completely different component than this one. Widens .wd-toc-col
1574
- itself only while it actually contains a non-empty host - the same
1575
- :has() technique ApiReferencePanel.astro's own identical comment
1576
- already uses to widen it for its own markup, so a page with neither
1577
- feature keeps the narrower 230px default from base.css. */
1578
- .wd-toc-col:has(.wd-example-host:not(:empty)) {
1579
- width: 340px;
1580
- }
1581
- .wd-example-host {
1582
- position: sticky;
1583
- top: var(--wd-topbar-offset, 5rem);
1584
- max-height: calc(100vh - var(--wd-topbar-offset, 5rem));
1585
- overflow-y: auto;
1586
- padding: 1.5rem 0 1.5rem 0.5rem;
1587
- }
1588
- /* Spacing between multiple docked panels (e.g. Request above
1589
- Response) is this wrapper's own job only once docked - inline
1590
- (mobile, no-toc-column, or not-yet-docked), the wrapped
1591
- .wd-codegroup's own default margin already spaces stacked panels
1592
- out correctly, so adding a second margin here unscoped would just
1593
- double it up. */
1594
- .wd-example-host .wd-example-panel {
1595
- margin-bottom: 1.25rem;
1596
- }
1597
- .wd-example-host .wd-example-panel:last-child {
1598
- margin-bottom: 0;
1599
- }
1600
- .wd-example-host .wd-codegroup {
1601
- margin: 0;
1602
- }
1603
-
1604
- .wd-example-host .astro-code {
1605
- margin: 0;
1606
- border-radius: 0 0 0.55rem 0.55rem;
1607
- }
1608
- </style>
1
+ ---
2
+ import { getCollection, render, type CollectionEntry } from "astro:content";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import {
6
+ loadDocsConfig,
7
+ resolveSections,
8
+ resolveGlobalDropdowns,
9
+ findSectionIndexForSlug,
10
+ buildNavTree,
11
+ ancestorGroupsForSlug,
12
+ buildSelectors,
13
+ buildGlobalDropdowns,
14
+ fileIdForEntry,
15
+ normalizeEntryId,
16
+ flattenNav,
17
+ firstSlugOfNavigation,
18
+ mergeSeo,
19
+ contextMenuOptions,
20
+ resolveSiteUrl,
21
+ findAllPages,
22
+ resolveLandings,
23
+ landingSelectors,
24
+ } from "../lib/config";
25
+ import { writedocsTempDir } from "../lib/writedocs-temp-dir.js";
26
+ import { throwIfOpenApiProblem } from "../lib/openapi-dev-status.js";
27
+ import { parseOpenApiRef } from "../lib/openapi-ref.js";
28
+ import { languageAlternates } from "../lib/item-pages.js";
29
+ import { wantsGeneratedCard, ogImagePath } from "../lib/og-image.js";
30
+ import BaseLayout from "../layout/BaseLayout.astro";
31
+ import Sidebar from "../layout/components/Sidebar.astro";
32
+ import TableOfContents from "../layout/components/TableOfContents.astro";
33
+ import Breadcrumbs from "../layout/components/Breadcrumbs.astro";
34
+ import CopyPageMenu from "../components/CopyPageMenu.astro";
35
+ import Callout from "../components/Callout.astro";
36
+ import Note from "../components/Note.astro";
37
+ import Info from "../components/Info.astro";
38
+ import Tip from "../components/Tip.astro";
39
+ import Warning from "../components/Warning.astro";
40
+ import Danger from "../components/Danger.astro";
41
+ import Card from "../components/Card.astro";
42
+ import CardGroup from "../components/CardGroup.astro";
43
+ import Tabs from "../components/Tabs.astro";
44
+ import Tab from "../components/Tab.astro";
45
+ import CodeGroup from "../components/CodeGroup.astro";
46
+ import Accordion from "../components/Accordion.astro";
47
+ import AccordionGroup from "../components/AccordionGroup.astro";
48
+ import Steps from "../components/Steps.astro";
49
+ import Step from "../components/Step.astro";
50
+ import Hint from "../components/Hint.astro";
51
+ import Image from "../components/Image.astro";
52
+ import Frame from "../components/Frame.astro";
53
+ import Video from "../components/Video.astro";
54
+ import Parameter from "../components/Parameter.astro";
55
+ import Expandable from "../components/Expandable.astro";
56
+ import Searchbar from "../components/Searchbar.astro";
57
+ import Badge from "../components/Badge.astro";
58
+ import Icon from "../components/Icon.astro";
59
+ import RequestExample from "../components/RequestExample.astro";
60
+ import ResponseExample from "../components/ResponseExample.astro";
61
+ import Check from "../components/Check.astro";
62
+ import ParamField from "../components/ParamField.astro";
63
+ import ResponseField from "../components/ResponseField.astro";
64
+ import Columns from "../components/Columns.astro";
65
+ import Column from "../components/Column.astro";
66
+ import CodeBlock from "../components/CodeBlock.astro";
67
+ import Tooltip from "../components/Tooltip.astro";
68
+ import Update from "../components/Update.astro";
69
+ import Tile from "../components/Tile.astro";
70
+ import Panel from "../components/Panel.astro";
71
+ import Prompt from "../components/Prompt.astro";
72
+ import View from "../components/View.astro";
73
+ import Visibility from "../components/Visibility.astro";
74
+ import { Tree, FileTree, Color, GitHub } from "../components/compound";
75
+ import ApiPlayground from "../components/ApiPlayground.astro";
76
+ import ApiReferencePanel from "../components/ApiReferencePanel.astro";
77
+ import { searchScope, sectionTrail, ALL_SCOPES } from "../lib/search-scope.js";
78
+ import { selectorPlacements } from "../lib/selector-placement.js";
79
+ import { spaceOf } from "../lib/hidden-sections.js";
80
+ import { navigationPageOrder } from "../lib/pages.js";
81
+ import { folderRedirects } from "../lib/folder-redirects.js";
82
+ import { DRAFT_BANNER_HTML } from "../lib/drafts.js";
83
+ import { oncePerBuild } from "../lib/build-memo.js";
84
+ // writedocs.json's `basePath` - the addresses below stay site addresses
85
+ // ("/guides/a/"); the base goes in where one is written (lib/site-base.ts).
86
+ import { siteHref } from "../lib/site-base";
87
+
88
+ // A page is hand-written (the `pages` collection, sourced from anywhere
89
+ // in the project - docs/ has no special status, see findAllPages() in
90
+ // lib/config.ts) or an auto-generated OpenAPI stub (the `generatedDocs`
91
+ // collection, sourced from writedocsTempDir()'s generated-docs/
92
+ // directory - see content.config.ts / generate-api-pages.js) - kept as two separate
93
+ // collections rather than one, since Astro's loader API has no supported
94
+ // way to point a single collection's glob() at more than one base
95
+ // directory without one's own cleanup pass deleting the other's entries
96
+ // (see content.config.ts's own comment on this). Both share the exact
97
+ // same schema, so every consumer below just treats them as one combined
98
+ // list.
99
+ //
100
+ // The two `getCollection()` calls below are inlined at each of their two
101
+ // call sites (getStaticPaths, and the component body further down)
102
+ // rather than factored into one shared top-level helper: Astro's
103
+ // getStaticPaths extraction (a separate bundling pass from the rest of
104
+ // the component - see the pathDescription comment further down for
105
+ // another instance of this) was observed to silently drop a top-level
106
+ // function declaration referenced from inside getStaticPaths, producing
107
+ // a raw "getAllDocsEntries is not defined" ReferenceError at build time
108
+ // instead of ever running. Keeping both call sites self-contained avoids
109
+ // relying on whatever static-analysis pass decides what counts as
110
+ // "used" by the extracted chunk.
111
+ //
112
+ // Each site also only calls getCollection('generatedDocs') when there's
113
+ // actually something in it (most sites have no OpenAPI groups - see
114
+ // generate-api-pages.js), rather than unconditionally calling it and
115
+ // letting content.config.ts's skipIfMissing() loader no-op internally:
116
+ // astro:content's own getCollection() logs "The collection ... does not
117
+ // exist or is empty" to the console whenever a collection ends up with
118
+ // zero registered entries, regardless of *why* it's empty - the data
119
+ // store has no supported way to mark a collection as "intentionally
120
+ // empty" short of writing at least one entry to it. Not calling
121
+ // getCollection() at all for an empty one sidesteps that warning at the
122
+ // source instead of trying to suppress it after the fact.
123
+ type DocsEntry = CollectionEntry<"pages"> | CollectionEntry<"generatedDocs">;
124
+
125
+ export async function getStaticPaths() {
126
+ const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
127
+ const packageRoot = process.env.WRITEDOCS_PACKAGE_ROOT || process.cwd();
128
+ const config = loadDocsConfig(contentDir);
129
+ const sections = resolveSections(config.navigation);
130
+ const hasGeneratedDocs = fs.existsSync(path.join(writedocsTempDir(contentDir), "generated-docs"));
131
+ const hasPages = findAllPages(contentDir).length > 0;
132
+ const [pagesEntries, generatedDocsEntries] = await Promise.all([
133
+ hasPages ? getCollection("pages") : Promise.resolve([]),
134
+ hasGeneratedDocs ? getCollection("generatedDocs") : Promise.resolve([]),
135
+ ]);
136
+ const entries: DocsEntry[] = [...pagesEntries, ...generatedDocsEntries];
137
+ // writedocs.json always references a page by its file id; `entry.id` is
138
+ // Astro's own resolved slug for it (the file-path default, or a
139
+ // frontmatter `slug` override it recognizes natively - see
140
+ // fileIdForEntry() in lib/config.ts) and is what the page is actually
141
+ // routed at. Keyed by file id so every navEntry.slug below finds its
142
+ // entry regardless of which one is in play.
143
+ const entryByFileId = new Map(entries.map((e) => [fileIdForEntry(contentDir, packageRoot, e), e]));
144
+
145
+ // "/" is only produced below when some page's *resolved* slug
146
+ // (entry.id) is literally "index" - the conventional home page (an
147
+ // index.mdx at the project root; a root-level index.mdx keeps file id
148
+ // "index" verbatim, since Astro's own default id computation only
149
+ // strips a trailing `/index` *segment*, which a single-segment root
150
+ // file doesn't have - see fileIdForEntry()'s own comment on this in
151
+ // lib/config.ts), or any page overriding its own slug to "index"/"/".
152
+ // Most navigations don't have such a page - Astro then warns "no
153
+ // matching static path was found for /" on every request. Rather than
154
+ // requiring every writedocs.json to name a page "index", synthesize a
155
+ // redirect-only route for "/" pointing at the site's first real page
156
+ // whenever nothing already claims root.
157
+ // Checked against every entry, not just nav-referenced ones - a hidden
158
+ // page (see hiddenRoutes below) sitting at "index" claims root exactly
159
+ // as well as a nav-listed one would, and needs to suppress the synthetic
160
+ // redirect below the same way (two routes both wanting `params.slug:
161
+ // undefined` is a build error, not a silent pick-one).
162
+ const rootAlreadyClaimed = entries.some((e) => normalizeEntryId(e.id) === "index");
163
+ const firstSlug = rootAlreadyClaimed ? null : firstSlugOfNavigation(config.navigation);
164
+ const firstEntry = firstSlug ? entryByFileId.get(firstSlug) : undefined;
165
+ // Not calling the top-level hrefForSlug() here: it's only otherwise
166
+ // referenced from the component body, not from inside getStaticPaths,
167
+ // and per the describeSectionPath lesson above, closures introduced
168
+ // into getStaticPaths should be self-contained rather than assume a
169
+ // module-level binding survives Astro's bundling extraction. firstEntry
170
+ // can never resolve to "index" here (that's exactly what
171
+ // rootAlreadyClaimed rules out), so the ternary below always resolves
172
+ // to the non-root branch.
173
+ const rootRedirect = firstEntry
174
+ ? [{ params: { slug: undefined }, props: { redirectTo: `/${normalizeEntryId(firstEntry.id)}/`, temporary: true } }]
175
+ : [];
176
+
177
+ // Tracks every file id a nav-driven route below already claims, so
178
+ // hiddenRoutes (further down) knows which entries are left over - any
179
+ // page/generatedDocs entry that exists (findAllPages() already required
180
+ // it to have frontmatter with a `title` - see content.config.ts's
181
+ // docsSchema) but isn't reachable by walking writedocs.json's navigation at
182
+ // all. Those still get routed here, just without a nav-derived
183
+ // prev/next or section - a page doesn't have to be in the sidebar to be
184
+ // a real, directly-linkable page (an in-progress draft, an unlisted
185
+ // landing page, etc.).
186
+ const claimedFileIds = new Set<string>();
187
+
188
+ const pageRoutes = sections.flatMap((section, sectionIndex) => {
189
+ const flatNav = flattenNav(section.pages);
190
+ // Prev/next skip pages that aren't in the sidebar (frontmatter
191
+ // `hidden`) or aren't pages at all (frontmatter `url`, an external
192
+ // link) - the reader should land on the next page they could also
193
+ // have clicked in the sidebar. Inlined for the same reason as the
194
+ // error branch below.
195
+ const isPaginationStop = (slug: string) => {
196
+ const data = entryByFileId.get(slug)?.data;
197
+ return Boolean(data) && !data!.hidden && !data!.url;
198
+ };
199
+ return flatNav.map((navEntry, i) => {
200
+ const entry = entryByFileId.get(navEntry.slug);
201
+ if (!entry) {
202
+ // Inlined rather than a separate top-level helper: Astro's
203
+ // getStaticPaths extraction (a separate bundling pass from the
204
+ // rest of the component) was observed to silently drop a
205
+ // top-level function declaration that's only referenced inside
206
+ // this rarely-taken branch, producing a raw "X is not defined"
207
+ // ReferenceError instead of this readable message. Keeping the
208
+ // logic inside getStaticPaths' own closure avoids relying on
209
+ // whatever static-analysis pass decides what counts as "used".
210
+ const pathDescription =
211
+ section.path.length === 0
212
+ ? "(root)"
213
+ : section.path
214
+ .map((seg) => {
215
+ const item = seg.items[seg.index] as Record<string, unknown>;
216
+ const name = (item.tab ?? item.version ?? item.language ?? item.dropdown ?? item.product) as string;
217
+ return `${seg.kind} "${name}"`;
218
+ })
219
+ .join(" > ");
220
+ throw new Error(
221
+ `[writedocs] writedocs.json references page "${navEntry.slug}"` +
222
+ ` (${pathDescription})` +
223
+ ` but no matching file was found`,
224
+ );
225
+ }
226
+ claimedFileIds.add(navEntry.slug);
227
+ const prev = flatNav.slice(0, i).findLast((e) => isPaginationStop(e.slug)) ?? null;
228
+ const next = flatNav.slice(i + 1).find((e) => isPaginationStop(e.slug)) ?? null;
229
+ const urlSlug = normalizeEntryId(entry.id);
230
+ // A frontmatter `url` page (Mintlify's external link) exists only
231
+ // to put that link in the sidebar - its own URL redirects there.
232
+ if (entry.data.url) {
233
+ return {
234
+ params: { slug: urlSlug === "index" ? undefined : urlSlug },
235
+ props: { redirectTo: entry.data.url },
236
+ };
237
+ }
238
+ return {
239
+ params: { slug: urlSlug === "index" ? undefined : urlSlug },
240
+ props: { entry, prev, next, sectionIndex },
241
+ };
242
+ });
243
+ });
244
+
245
+ // An item's own page (a tab's, a dropdown's, ... `page` - resolveLandings()
246
+ // in lib/config.ts) that no sidebar lists: shown inside its item. One the
247
+ // sidebar does list was routed above, in its sidebar. Its Next is the
248
+ // item's first sidebar page, if the item has a sidebar of its own.
249
+ const landings = resolveLandings(config.navigation);
250
+ const landingRoutes = landings.flatMap((landing, landingIndex) => {
251
+ if (claimedFileIds.has(landing.slug)) return [];
252
+ const entry = entryByFileId.get(landing.slug);
253
+ if (!entry) {
254
+ const last = landing.path[landing.path.length - 1];
255
+ const item = landing.item as Record<string, unknown>;
256
+ const name = (item.tab ?? item.version ?? item.language ?? item.dropdown ?? item.product) as string;
257
+ throw new Error(
258
+ `[writedocs] writedocs.json's ${last.kind} "${name}" names page "${landing.slug}" as its own page,` +
259
+ ` but no matching file was found`,
260
+ );
261
+ }
262
+ claimedFileIds.add(landing.slug);
263
+ const next =
264
+ flattenNav(landing.pages).find((e) => {
265
+ const data = entryByFileId.get(e.slug)?.data;
266
+ return Boolean(data) && !data!.hidden && !data!.url;
267
+ }) ?? null;
268
+ const urlSlug = normalizeEntryId(entry.id);
269
+ if (entry.data.url) {
270
+ return [{ params: { slug: urlSlug === "index" ? undefined : urlSlug }, props: { redirectTo: entry.data.url } }];
271
+ }
272
+ return [
273
+ { params: { slug: urlSlug === "index" ? undefined : urlSlug }, props: { entry, prev: null, next, landingIndex } },
274
+ ];
275
+ });
276
+
277
+ // "Hidden" pages: any file the `pages`/`generatedDocs` collections
278
+ // picked up that writedocs.json's navigation never references (see
279
+ // claimedFileIds above) still gets a real route here - just with no
280
+ // prev/next (nothing in nav to derive that from) and no section of its
281
+ // own to be "active" in. findSectionIndexForSlug's existing "0 if this
282
+ // slug isn't in any section" fallback (already used nowhere else in
283
+ // this file, but built for exactly this) picks which section's
284
+ // sidebar/selectors a hidden page borrows - arbitrary, but no worse
285
+ // than the alternative of hidden pages having no chrome at all.
286
+ const hiddenRoutes = entries
287
+ .filter((entry) => !claimedFileIds.has(fileIdForEntry(contentDir, packageRoot, entry)))
288
+ .map((entry) => {
289
+ const urlSlug = normalizeEntryId(entry.id);
290
+ return {
291
+ params: { slug: urlSlug === "index" ? undefined : urlSlug },
292
+ props: {
293
+ entry,
294
+ prev: null,
295
+ next: null,
296
+ sectionIndex: findSectionIndexForSlug(sections, fileIdForEntry(contentDir, packageRoot, entry)),
297
+ isHidden: true,
298
+ },
299
+ };
300
+ });
301
+
302
+ // Folder addresses with pages under them but none of their own
303
+ // (`/docs/creator/`) redirect to the first page under them
304
+ // (lib/folder-redirects.js). Preferred in the reader's order: navigation
305
+ // order, public sections before hidden ones, pages outside the
306
+ // navigation last.
307
+ const slugOf = (route: { params: { slug?: string } }) => route.params.slug ?? "index";
308
+ const inHiddenSection = sections.map((section) => spaceOf(section.path) !== null);
309
+ const contentRoutes = pageRoutes.filter((route) => !("redirectTo" in route.props));
310
+ // An item's own page counts where the navigation names it: before the
311
+ // item's sidebar (navigationPageOrder()), so `/guides/` opens the Guides
312
+ // tab's own page rather than its first sidebar page.
313
+ type ContentRoute = {
314
+ params: { slug?: string };
315
+ props: { entry?: DocsEntry; sectionIndex?: number; landingIndex?: number };
316
+ };
317
+ const navOrder = new Map(navigationPageOrder(config.navigation).map((id, i) => [id, i]));
318
+ const orderOf = (route: ContentRoute) =>
319
+ navOrder.get(fileIdForEntry(contentDir, packageRoot, route.props.entry!)) ?? Infinity;
320
+ const inHiddenItem = (route: ContentRoute) =>
321
+ route.props.landingIndex !== undefined
322
+ ? spaceOf(landings[route.props.landingIndex].path) !== null
323
+ : inHiddenSection[route.props.sectionIndex!];
324
+ const navContent = [
325
+ ...contentRoutes,
326
+ ...landingRoutes.filter((route) => !("redirectTo" in route.props)),
327
+ ] as ContentRoute[];
328
+ const folderTargets = [
329
+ ...navContent
330
+ .filter((route) => !inHiddenItem(route))
331
+ .sort((a, b) => orderOf(a) - orderOf(b))
332
+ .map(slugOf),
333
+ ...navContent
334
+ .filter(inHiddenItem)
335
+ .sort((a, b) => orderOf(a) - orderOf(b))
336
+ .map(slugOf),
337
+ ...hiddenRoutes.map(slugOf),
338
+ ];
339
+ const takenAddresses = new Set([
340
+ ...[...pageRoutes, ...landingRoutes, ...hiddenRoutes].map(slugOf),
341
+ ...(config.redirects ?? []).map((r) => r.source.replace(/^\/+|\/+$/g, "")),
342
+ ]);
343
+ const folderRoutes = [...folderRedirects(folderTargets, takenAddresses)].map(([folder, target]) => ({
344
+ params: { slug: folder },
345
+ props: { redirectTo: `/${target}/`, temporary: true },
346
+ }));
347
+
348
+ return [...rootRedirect, ...pageRoutes, ...landingRoutes, ...hiddenRoutes, ...folderRoutes];
349
+ }
350
+
351
+ interface Props {
352
+ redirectTo?: string;
353
+ // The automatic "/" and folder redirects: temporary, see below.
354
+ temporary?: boolean;
355
+ entry?: DocsEntry;
356
+ prev?: { slug: string; group: string | null } | null;
357
+ next?: { slug: string; group: string | null } | null;
358
+ sectionIndex?: number;
359
+ // Set by hiddenRoutes in getStaticPaths above - a page with no place in
360
+ // writedocs.json's navigation has no sidebar section of its own to show, so
361
+ // its default mode drops the sidebar entirely (see pageMode below)
362
+ // rather than borrowing findSectionIndexForSlug's arbitrary fallback
363
+ // section's sidebar contents, which would misleadingly suggest the page
364
+ // belongs there.
365
+ isHidden?: boolean;
366
+ // Set by landingRoutes in getStaticPaths above - an item's own page that
367
+ // no sidebar lists, shown inside that item (index into resolveLandings()).
368
+ landingIndex?: number;
369
+ }
370
+
371
+ const rawProps = Astro.props as Props;
372
+ if (rawProps.redirectTo) {
373
+ // The automatic "/" redirect is temporary (302): its target is just the
374
+ // navigation's first page, and it goes away once the site has a page at
375
+ // "/". A 301 is remembered by the browser for good - after that, "/" kept
376
+ // redirecting even with a home page in place, in `writedocs dev` (every
377
+ // project's preview shares localhost:4321) and for returning visitors.
378
+ // A frontmatter `url` page stays 301. In a static build the status only
379
+ // picks the refresh delay of Astro's redirect page, and the build rewrites
380
+ // those pages to redirect at once either way (rewrite-redirect-pages.js).
381
+ return Astro.redirect(siteHref(rawProps.redirectTo), rawProps.temporary ? 302 : 301);
382
+ }
383
+ const {
384
+ entry,
385
+ prev = null,
386
+ next = null,
387
+ sectionIndex = 0,
388
+ isHidden = false,
389
+ landingIndex,
390
+ } = rawProps as Required<Props>;
391
+
392
+ const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
393
+ const packageRoot = process.env.WRITEDOCS_PACKAGE_ROOT || process.cwd();
394
+ // `writedocs dev`, with an OpenAPI spec that stopped parsing: the error
395
+ // instead of the page, until it parses again (lib/openapi-dev-status.js).
396
+ throwIfOpenApiProblem(contentDir);
397
+ const config = loadDocsConfig(contentDir);
398
+ // Once per build, like the lookup tables further down.
399
+ const sections = oncePerBuild("slug:sections", () => resolveSections(config.navigation));
400
+ // Falls back to an empty stand-in section rather than crashing on
401
+ // `.pages` below - only reachable for a hidden page (see hiddenRoutes in
402
+ // getStaticPaths above) on a site whose writedocs.json has no navigation
403
+ // sections at all, which previously could never produce a route to
404
+ // render in the first place.
405
+ // An item's own page shown inside its item (landingRoutes above): the item's
406
+ // path, and its own sidebar if it has one.
407
+ const landing =
408
+ landingIndex === undefined
409
+ ? undefined
410
+ : oncePerBuild("slug:landings", () => resolveLandings(config.navigation))[landingIndex];
411
+ const activeSection = landing
412
+ ? { pages: landing.pages, path: landing.path }
413
+ : (sections[sectionIndex] ?? { pages: [], path: [] });
414
+
415
+ const { Content, headings } = await render(entry);
416
+ const tocHeadings = headings.filter((h) => h.depth === 2 || h.depth === 3);
417
+
418
+ // The lookup tables below are the same for every page, so a build makes
419
+ // them once (oncePerBuild(), lib/build-memo.js) - findAllPages() alone reads
420
+ // every page file of the project, and ran here once per page. In
421
+ // `writedocs dev` they're made again on every request, as before.
422
+ const { titleByFileId, navTitleByFileId, entryByFileId, methodByFileId } = await oncePerBuild(
423
+ "slug:lookups",
424
+ async () => {
425
+ const hasGeneratedDocs = fs.existsSync(path.join(writedocsTempDir(contentDir), "generated-docs"));
426
+ const hasPages = findAllPages(contentDir).length > 0;
427
+ const [pagesEntries, generatedDocsEntries] = await Promise.all([
428
+ hasPages ? getCollection("pages") : Promise.resolve([]),
429
+ hasGeneratedDocs ? getCollection("generatedDocs") : Promise.resolve([]),
430
+ ]);
431
+ const entries: DocsEntry[] = [...pagesEntries, ...generatedDocsEntries];
432
+ // Two maps keyed by file id (not `entry.id` - see fileIdForEntry() in
433
+ // lib/config.ts for why those can differ once a page overrides its own
434
+ // slug): titles for prev/next and sidebar labels, and the entries
435
+ // themselves so hrefForSlug can resolve a writedocs.json file-id reference to
436
+ // wherever that page actually got routed.
437
+ const titleByFileId = new Map<string, string>();
438
+ // Navigation labels (sidebar, topbar dropdowns): a page's `sidebarTitle`
439
+ // when it has one - Mintlify's short nav label - else its `title`.
440
+ const navTitleByFileId = new Map<string, string>();
441
+ const entryByFileId = new Map<string, DocsEntry>();
442
+ // The HTTP method badge NavTree.astro shows next to an API operation
443
+ // page in the sidebar - read straight off the page's own `openapi:
444
+ // "METHOD /path"` frontmatter rather than the resolved operation JSON,
445
+ // since the method itself is right there in that string already and
446
+ // doesn't need a spec lookup.
447
+ const methodByFileId = new Map<string, string>();
448
+ for (const e of entries) {
449
+ const fileId = fileIdForEntry(contentDir, packageRoot, e);
450
+ titleByFileId.set(fileId, e.data.title);
451
+ navTitleByFileId.set(fileId, e.data.sidebarTitle ?? e.data.title);
452
+ entryByFileId.set(fileId, e);
453
+ // `hideApiMarker` (Mintlify's) drops the badge for this one page.
454
+ const apiRef = parseOpenApiRef(e.data.openapi);
455
+ if (apiRef && !e.data.hideApiMarker) {
456
+ methodByFileId.set(fileId, apiRef.method);
457
+ }
458
+ }
459
+ return { titleByFileId, navTitleByFileId, entryByFileId, methodByFileId };
460
+ },
461
+ );
462
+ const titleForSlug = (slug: string) => titleByFileId.get(slug) ?? slug;
463
+ const navTitleForSlug = (slug: string) => navTitleByFileId.get(slug) ?? slug;
464
+ const methodForSlug = (slug: string) => methodByFileId.get(slug) ?? null;
465
+ // Frontmatter that changes how a page appears in navigation (hidden, url,
466
+ // icon, tag, deprecated) - see buildNavTree() in lib/config.ts.
467
+ const navMetaForSlug = (slug: string) => entryByFileId.get(slug)?.data;
468
+ const hrefForSlug = (slug: string) => {
469
+ const raw = entryByFileId.get(slug)?.id ?? slug;
470
+ const effective = normalizeEntryId(raw);
471
+ return effective === "index" ? "/" : `/${effective}/`;
472
+ };
473
+ // The current page's own file id (as writedocs.json references it) - distinct
474
+ // from `entry.id` (its resolved URL slug) for the same reason as above,
475
+ // and what every "is this the active page" comparison below needs, since
476
+ // navTree/globalDropdowns are built from writedocs.json's file-id space.
477
+ const currentFileId = fileIdForEntry(contentDir, packageRoot, entry);
478
+ // A section's tree doesn't depend on which of its pages is open (NavTree.astro
479
+ // marks the current one), so it's built once per section in a build.
480
+ const navTree = oncePerBuild(`slug:nav:${landingIndex === undefined ? `s${sectionIndex}` : `l${landingIndex}`}`, () =>
481
+ buildNavTree(activeSection.pages, navTitleForSlug, methodForSlug, navMetaForSlug),
482
+ );
483
+ // The ancestor sidebar-group trail above the auto <h1> (Breadcrumbs.astro)
484
+ // - empty for a page sitting at the top level of its Section with no
485
+ // enclosing group, in which case [...slug].astro below skips rendering
486
+ // the component entirely rather than showing a breadcrumb bar with
487
+ // nothing in it but the page's own title.
488
+ const breadcrumbs = ancestorGroupsForSlug(navTree, currentFileId, hrefForSlug);
489
+
490
+ // The reader's page's own position within the active Section's flattened
491
+ // pages list - passed to buildSelectors() so a version/language switch
492
+ // can try to land on the *same* page in the target option instead of
493
+ // always its first page (equivalentPageIn() in lib/config.ts). -1 (not
494
+ // found) just disables that - firstSlugOf() is still the fallback.
495
+ const activePagePosition = flattenNav(activeSection.pages).findIndex((e) => e.slug === currentFileId);
496
+
497
+ // One selector per level of the active page's navigation path (tabs,
498
+ // versions, languages, products, or a dropdown nested partway down),
499
+ // plus the always-visible global dropdown list - see BaseLayout.astro
500
+ // for how each renders.
501
+ // An item's own page also gets the level under the item, with nothing chosen.
502
+ const selectors = landing
503
+ ? landingSelectors(landing, hrefForSlug)
504
+ : buildSelectors(activeSection.path, hrefForSlug, activePagePosition);
505
+ // <html lang>: the `language` of the navigation level this page sits under,
506
+ // if any. A hidden page has no level of its own (activeSection is only a
507
+ // fallback for its chrome), so it keeps the default.
508
+ // For search: the section line under this page's result (and words it can
509
+ // be found by), and the version/language/product it belongs to - search
510
+ // shows the reader's own first. A hidden page belongs to no section.
511
+ const pageSearchScope = isHidden ? { key: ALL_SCOPES, label: "" } : searchScope(activeSection.path);
512
+ // A draft (only in `writedocs dev` and `build --drafts` - lib/drafts.js)
513
+ // says so on its search result's section line.
514
+ const pageSectionTrail = [entry.data.draft ? "Draft" : "", isHidden ? "" : sectionTrail(activeSection.path, breadcrumbs)]
515
+ .filter(Boolean)
516
+ .join(" · ");
517
+ // A page under a hidden navigation item searches its own index, not the
518
+ // site's (lib/hidden-sections.js, cli/run-pagefind.js).
519
+ const pageSearchSpace = isHidden ? null : spaceOf(activeSection.path);
520
+ const languageSegment = isHidden ? undefined : activeSection.path.find((segment) => segment.kind === "language");
521
+ const pageLang = languageSegment
522
+ ? (languageSegment.items[languageSegment.index] as { language: string }).language
523
+ : undefined;
524
+ const globalDropdowns = buildGlobalDropdowns(
525
+ resolveGlobalDropdowns(config.navigation),
526
+ currentFileId,
527
+ navTitleForSlug,
528
+ hrefForSlug,
529
+ navMetaForSlug,
530
+ );
531
+
532
+ // Meta tags: this page's own frontmatter `seo` overrides writedocs.json's
533
+ // site-wide `seo` field by field (mergeSeo() in lib/config.ts), and the
534
+ // canonical/OG/Twitter URLs need this page's actual served path - reusing
535
+ // hrefForSlug (already built above for prev/next and the sidebar) rather
536
+ // than recomputing it, since it already encodes the same
537
+ // frontmatter-slug-override-aware routing logic.
538
+ const pageSeo = mergeSeo(config.seo, entry.data.seo);
539
+ // A page with no picture of its own for link previews gets the generated
540
+ // card (lib/og-image.js, served by src/pages/og/[...slug].png.ts).
541
+ if (wantsGeneratedCard(pageSeo, entry.data, config.seo)) pageSeo.ogImage = ogImagePath(normalizeEntryId(entry.id));
542
+ const currentPath = hrefForSlug(currentFileId);
543
+ // This page in each language, for hreflang (languageAlternates() in
544
+ // lib/item-pages.js) - a hidden page belongs to no language level.
545
+ const alternates = isHidden
546
+ ? []
547
+ : languageAlternates(activeSection.path, currentFileId, activeSection.pages, landing !== undefined).map((a) => ({
548
+ lang: a.lang,
549
+ href: hrefForSlug(a.slug),
550
+ }));
551
+ // The trail for the page's structured data (lib/json-ld.js): home, the
552
+ // groups above the page that have a page of their own, the page.
553
+ const structuredTrail = [
554
+ { name: config.name, href: "/" },
555
+ ...breadcrumbs.filter((crumb) => crumb.href).map((crumb) => ({ name: crumb.label, href: crumb.href as string })),
556
+ ...(currentPath === "/" ? [] : [{ name: entry.data.title, href: currentPath }]),
557
+ ];
558
+
559
+ // Page mode (content.config.ts's docsSchema `mode` field, defaulted to
560
+ // 'default' there so this is never actually undefined) - see
561
+ // BaseLayout.astro for what each value strips out of the topbar/shell,
562
+ // and the comment on <BaseLayout mode=...> below for what this file
563
+ // itself controls (which slots get filled at all, and how the article
564
+ // itself renders).
565
+ // A hidden page (isHidden - see hiddenRoutes/Props above) defaults to
566
+ // "frame" instead of "default": it has no real section of its own, so
567
+ // the sidebar would otherwise show findSectionIndexForSlug's arbitrary
568
+ // fallback section with nothing in it actually active - "frame" drops
569
+ // the sidebar (and ToC) while keeping the topbar and normal article
570
+ // styling. Only a *default*: a hidden page's own frontmatter mode, if
571
+ // it set one explicitly, still wins.
572
+ // An item's own page with nothing for a sidebar - the item holds tabs, or
573
+ // versions, ... that switch elsewhere - is laid out the same way.
574
+ const landingWithoutSidebar =
575
+ landing !== undefined &&
576
+ flattenNav(landing.pages).length === 0 &&
577
+ !selectorPlacements(selectors, { sidebar: true }).includes("sidebar");
578
+ const pageMode = (isHidden || landingWithoutSidebar) && entry.data.mode === "default" ? "frame" : entry.data.mode;
579
+ const showSidebar = pageMode === "default" || pageMode === "wide";
580
+ // Products inside a tab or dropdown switch at the top of the sidebar, not in
581
+ // the top bar (lib/selector-placement.js - TopBar.astro applies the same rule).
582
+ const sidebarPlacements = selectorPlacements(selectors, { sidebar: showSidebar });
583
+ const sidebarSwitchers = selectors.filter((_, i) => sidebarPlacements[i] === "sidebar");
584
+ const showToc = pageMode === "default";
585
+ // 'custom' and 'blank' both get the bare wd-canvas treatment below (no
586
+ // auto <h1>, no prev/next, no prose width/padding) - they only differ in
587
+ // whether BaseLayout keeps the topbar, which is BaseLayout's own concern
588
+ // (mode is passed straight through), not something this file needs to
589
+ // branch on separately.
590
+ const isCanvasMode = pageMode === "custom" || pageMode === "blank";
591
+
592
+ // The "Copy page" menu (CopyPageMenu.astro) - on by default, with the
593
+ // options writedocs.json's `contextMenu` leaves on (contextMenuOptions() in
594
+ // lib/config-schema.ts; `false` turns it off), and only
595
+ // shown where there's a real auto-rendered <h1> to sit next to: canvas
596
+ // mode pages (custom/blank) have no such header (a hand-built landing
597
+ // page controls its own layout, there's nothing standard to anchor the
598
+ // menu to), and OpenAPI operation pages render almost entirely from the
599
+ // spec rather than prose - see [...slug].md.ts's own comment on why
600
+ // those are excluded from the .md route this menu links to in the first
601
+ // place, which this mirrors on the UI side.
602
+ const contextMenuItems = contextMenuOptions(config.contextMenu, { mcp: config.mcp });
603
+ const showCopyPageMenu = contextMenuItems.length > 0 && !isCanvasMode;
604
+ const siteUrl = resolveSiteUrl(config);
605
+
606
+ const components = {
607
+ Callout,
608
+ Note,
609
+ Info,
610
+ Tip,
611
+ Warning,
612
+ Danger,
613
+ Card,
614
+ CardGroup,
615
+ Tabs,
616
+ Tab,
617
+ CodeGroup,
618
+ Accordion,
619
+ AccordionGroup,
620
+ Steps,
621
+ Step,
622
+ Hint,
623
+ Image,
624
+ Frame,
625
+ Video,
626
+ Parameter,
627
+ Expandable,
628
+ Searchbar,
629
+ Badge,
630
+ Icon,
631
+ RequestExample,
632
+ ResponseExample,
633
+ Check,
634
+ ParamField,
635
+ ResponseField,
636
+ Columns,
637
+ Column,
638
+ CodeBlock,
639
+ Tooltip,
640
+ Update,
641
+ Tile,
642
+ Panel,
643
+ Prompt,
644
+ View,
645
+ Visibility,
646
+ Tree,
647
+ FileTree,
648
+ Color,
649
+ GitHub,
650
+ };
651
+ ---
652
+
653
+ <BaseLayout
654
+ config={config}
655
+ title={entry.data.title}
656
+ description={entry.data.description}
657
+ path={currentPath}
658
+ seo={pageSeo}
659
+ selectors={selectors}
660
+ globalDropdowns={globalDropdowns}
661
+ mode={pageMode}
662
+ lang={pageLang}
663
+ alternates={alternates}
664
+ breadcrumbs={structuredTrail}
665
+ isApi={Boolean(entry.data.openapi)}
666
+ >
667
+ {
668
+ showSidebar && (
669
+ <Sidebar
670
+ slot="sidebar"
671
+ navTree={navTree}
672
+ hrefForSlug={hrefForSlug}
673
+ currentSlug={currentFileId}
674
+ switchers={sidebarSwitchers}
675
+ />
676
+ )
677
+ }
678
+ {
679
+ isCanvasMode ? (
680
+ // 'custom' and 'blank' both get this treatment: no auto <h1>, no
681
+ // prev/next nav, none of .wd-article's own prose max-width/padding -
682
+ // just the page's own MDX/component content, edge to edge. Still gets
683
+ // a data-pagefind-body wrapper so a hand-built page's own text is
684
+ // still searchable.
685
+ <div class="wd-canvas" data-pagefind-body>
686
+ {entry.data.draft && <Fragment set:html={DRAFT_BANNER_HTML} />}
687
+ <Content components={components} />
688
+ {entry.data.openapi && <ApiPlayground operation={entry.data.openapi} contentDir={contentDir} />}
689
+ {/* After the content: a result's excerpt shows the section only when
690
+ that's what matched. */}
691
+ <div
692
+ hidden
693
+ data-markdown-ignore
694
+ data-wd-search-scope={pageSearchScope.key}
695
+ data-wd-search-scope-label={pageSearchScope.label}
696
+ data-wd-search-space={pageSearchSpace?.id}
697
+ data-wd-search-public={pageSearchSpace?.searchPublic ? "true" : undefined}
698
+ data-pagefind-filter={`scope:${pageSearchScope.key}`}
699
+ >
700
+ {pageSectionTrail && <span data-pagefind-meta="section">{pageSectionTrail}</span>}
701
+ </div>
702
+ </div>
703
+ ) : (
704
+ <article class={`wd-article ${pageMode === "wide" ? "wd-article-wide" : ""}`} data-pagefind-body>
705
+ {
706
+ // A draft page - only in `writedocs dev` and `build --drafts`
707
+ // (lib/drafts.js): a strip at the top saying so.
708
+ entry.data.draft && <Fragment set:html={DRAFT_BANNER_HTML} />
709
+ }
710
+ {breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} />}
711
+ <div class="wd-article-header">
712
+ {
713
+ // Frontmatter `deprecated` puts a label beside the <h1>, not in
714
+ // it - the <h1>'s text is the search index's page title.
715
+ entry.data.deprecated ? (
716
+ <div class="wd-article-title">
717
+ <h1 data-pagefind-meta="title">{entry.data.title}</h1>
718
+ <span class="wd-deprecated-badge">Deprecated</span>
719
+ </div>
720
+ ) : (
721
+ <h1 data-pagefind-meta="title">{entry.data.title}</h1>
722
+ )
723
+ }
724
+ {showCopyPageMenu && (
725
+ <CopyPageMenu
726
+ currentPath={currentPath}
727
+ siteUrl={siteUrl}
728
+ siteName={config.name}
729
+ options={contextMenuItems}
730
+ />
731
+ )}
732
+ </div>
733
+ <Content components={components} />
734
+ {entry.data.openapi && <ApiPlayground operation={entry.data.openapi} contentDir={contentDir} />}
735
+ <div
736
+ hidden
737
+ data-markdown-ignore
738
+ data-wd-search-scope={pageSearchScope.key}
739
+ data-wd-search-scope-label={pageSearchScope.label}
740
+ data-wd-search-space={pageSearchSpace?.id}
741
+ data-wd-search-public={pageSearchSpace?.searchPublic ? "true" : undefined}
742
+ data-pagefind-filter={`scope:${pageSearchScope.key}`}
743
+ >
744
+ {pageSectionTrail && <span data-pagefind-meta="section">{pageSectionTrail}</span>}
745
+ </div>
746
+ {!entry.data.hideFooterPagination && (
747
+ <nav class="wd-prevnext" data-pagefind-ignore data-markdown-ignore>
748
+ {prev && (
749
+ <a class="wd-prevnext-card wd-prevnext-prev" href={siteHref(hrefForSlug(prev.slug))}>
750
+ <span class="wd-prevnext-row">
751
+ <svg
752
+ class="wd-prevnext-icon"
753
+ width="16"
754
+ height="16"
755
+ viewBox="0 0 24 24"
756
+ fill="none"
757
+ stroke="currentColor"
758
+ stroke-width="2"
759
+ stroke-linecap="round"
760
+ stroke-linejoin="round"
761
+ aria-hidden="true"
762
+ >
763
+ <line x1="19" y1="12" x2="5" y2="12" />
764
+ <polyline points="12 19 5 12 12 5" />
765
+ </svg>
766
+ <span class="wd-prevnext-label">Previous</span>
767
+ </span>
768
+ <span class="wd-prevnext-title">{titleForSlug(prev.slug)}</span>
769
+ </a>
770
+ )}
771
+ {next && (
772
+ <a class="wd-prevnext-card wd-prevnext-next" href={siteHref(hrefForSlug(next.slug))}>
773
+ <span class="wd-prevnext-row">
774
+ <span class="wd-prevnext-label">Next</span>
775
+ <svg
776
+ class="wd-prevnext-icon"
777
+ width="16"
778
+ height="16"
779
+ viewBox="0 0 24 24"
780
+ fill="none"
781
+ stroke="currentColor"
782
+ stroke-width="2"
783
+ stroke-linecap="round"
784
+ stroke-linejoin="round"
785
+ aria-hidden="true"
786
+ >
787
+ <line x1="5" y1="12" x2="19" y2="12" />
788
+ <polyline points="12 5 19 12 12 19" />
789
+ </svg>
790
+ </span>
791
+ <span class="wd-prevnext-title">{titleForSlug(next.slug)}</span>
792
+ </a>
793
+ )}
794
+ </nav>
795
+ )}
796
+ </article>
797
+ )
798
+ }
799
+ {
800
+ showToc &&
801
+ (entry.data.openapi ? (
802
+ <ApiReferencePanel slot="toc" operation={entry.data.openapi} contentDir={contentDir} />
803
+ ) : (
804
+ <TableOfContents slot="toc" headings={tocHeadings} />
805
+ ))
806
+ }
807
+ </BaseLayout>
808
+
809
+ <script>
810
+ import { mcpServerUrl, cursorInstallLink, vscodeInstallLink } from "../lib/mcp-links.js";
811
+ // writedocs.json's `basePath` ("" or "/docs", astro.config.mjs) - the MCP
812
+ // server is at the site's root, under it. Written as `__WD_BASE__ ? ... : ...`
813
+ // so a site without one gets the same code as before basePath existed.
814
+ declare const __WD_BASE__: string;
815
+
816
+ // Astro assigns every h2-h4 an id automatically, but doesn't add a
817
+ // clickable anchor next to it. rehype-autolink-headings can't be used
818
+ // for this directly: Astro's own heading-id rehype plugin always runs
819
+ // AFTER any user-supplied rehypePlugins in its pipeline, so a plugin
820
+ // that links existing ids never sees them. Adding the anchor client-side
821
+ // sidesteps that ordering constraint entirely.
822
+ function addHeadingAnchors(root: ParentNode) {
823
+ root
824
+ .querySelectorAll<HTMLElement>(".wd-article > h2[id], .wd-article > h3[id], .wd-article > h4[id]")
825
+ .forEach((heading) => {
826
+ if (heading.querySelector(".wd-heading-anchor")) return;
827
+ const anchor = document.createElement("a");
828
+ anchor.className = "wd-heading-anchor";
829
+ anchor.href = `#${heading.id}`;
830
+ anchor.setAttribute("aria-label", "Link to this section");
831
+ anchor.textContent = "#";
832
+ heading.appendChild(anchor);
833
+ });
834
+ }
835
+ addHeadingAnchors(document);
836
+ document.addEventListener("astro:page-load", () => addHeadingAnchors(document));
837
+
838
+ // Copy-to-clipboard button for every fenced (```) code block - the
839
+ // button itself is emitted at build time by codeBlockTransformer
840
+ // (astro.config.mjs / src/lib/shiki-code-block.js), wrapping each
841
+ // <pre> in a .wd-code-block container; this just wires up the click
842
+ // behavior client-side, same dataset-guarded init pattern as
843
+ // addHeadingAnchors above.
844
+ function initCodeCopyButtons(root: ParentNode) {
845
+ root.querySelectorAll<HTMLButtonElement>(".wd-code-copy-btn").forEach((btn) => {
846
+ if (btn.dataset.wdInit) return;
847
+ btn.dataset.wdInit = "true";
848
+ btn.addEventListener("click", async () => {
849
+ const pre = btn.closest(".wd-code-block")?.querySelector("pre");
850
+ if (!pre) return;
851
+ try {
852
+ await navigator.clipboard.writeText(pre.textContent ?? "");
853
+ } catch {
854
+ return; // clipboard unavailable (e.g. insecure context) - fail silently
855
+ }
856
+ btn.textContent = "✓";
857
+ btn.classList.add("wd-code-copied");
858
+ window.setTimeout(() => {
859
+ btn.textContent = "⧉";
860
+ btn.classList.remove("wd-code-copied");
861
+ }, 1500);
862
+ });
863
+ });
864
+ }
865
+ initCodeCopyButtons(document);
866
+ document.addEventListener("astro:page-load", () => initCodeCopyButtons(document));
867
+
868
+ // Clipboard-copy button for CopyPageMenu.astro's primary "Copy page"
869
+ // button (the split button's left half - the right half is just a
870
+ // .wd-dropdown-trigger caret, handled by BaseLayout's own
871
+ // initDropdowns()) - same dataset-guarded init pattern as
872
+ // initCodeCopyButtons above, but fetches its content from the button's
873
+ // own data-md-path (the [...slug].md.ts route for the current page -
874
+ // see CopyPageMenu.astro) rather than reading it from an
875
+ // already-rendered element on the page, since the raw Markdown source
876
+ // isn't otherwise present in the DOM anywhere (the rendered HTML
877
+ // content is not the same text).
878
+ function initCopyPageMenu(root: ParentNode) {
879
+ root.querySelectorAll<HTMLButtonElement>("button[data-copy-page]").forEach((btn) => {
880
+ if (btn.dataset.wdInit) return;
881
+ btn.dataset.wdInit = "true";
882
+ const label = btn.querySelector<HTMLElement>(".wd-copy-page-primary-label");
883
+ const originalLabel = label?.textContent ?? "Copy page";
884
+ btn.addEventListener("click", async () => {
885
+ const mdPath = btn.dataset.mdPath;
886
+ if (!mdPath) return;
887
+ try {
888
+ const res = await fetch(mdPath);
889
+ const text = await res.text();
890
+ await navigator.clipboard.writeText(text);
891
+ } catch {
892
+ return; // fetch/clipboard unavailable - fail silently, same as initCodeCopyButtons
893
+ }
894
+ btn.classList.add("wd-copy-page-copied");
895
+ if (label) label.textContent = "Copied!";
896
+ window.setTimeout(() => {
897
+ btn.classList.remove("wd-copy-page-copied");
898
+ if (label) label.textContent = originalLabel;
899
+ }, 1500);
900
+ });
901
+ });
902
+ }
903
+ initCopyPageMenu(document);
904
+ document.addEventListener("astro:page-load", () => initCopyPageMenu(document));
905
+
906
+ // "Open in ChatGPT/Claude/Perplexity" on a site with no writedocs.json
907
+ // `domain`: the page's absolute .md URL isn't known at build time, so the
908
+ // link is completed here from the address the page is served from (see
909
+ // CopyPageMenu.astro) - same prompt the build writes when it does know.
910
+ function initAskLinks(root: ParentNode) {
911
+ root.querySelectorAll<HTMLAnchorElement>("a[data-ask-base][data-md-path]").forEach((link) => {
912
+ const url = new URL(link.dataset.mdPath ?? "/", window.location.origin).href;
913
+ link.href = link.dataset.askBase + encodeURIComponent(`Read ${url} so you can answer questions about it.`);
914
+ });
915
+ }
916
+ initAskLinks(document);
917
+ document.addEventListener("astro:page-load", () => initAskLinks(document));
918
+
919
+ // The menu's MCP options (CopyPageMenu.astro). "Copy MCP server URL"
920
+ // copies it and says so in its own label - inside the menu, which stays
921
+ // open to show it. "Connect to Cursor / VS Code" on a site with no
922
+ // `domain` get their install links here, for the address the page is
923
+ // served from.
924
+ function initMcpMenu(root: ParentNode) {
925
+ const serverUrl = (el: HTMLElement) =>
926
+ el.dataset.copyMcp || mcpServerUrl(__WD_BASE__ ? window.location.origin + __WD_BASE__ : window.location.origin);
927
+ root.querySelectorAll<HTMLButtonElement>("button[data-copy-mcp]").forEach((btn) => {
928
+ if (btn.dataset.wdInit) return;
929
+ btn.dataset.wdInit = "true";
930
+ const label = btn.querySelector<HTMLElement>(".wd-copy-page-item-title, .wd-copy-page-primary-label");
931
+ const originalLabel = label?.textContent ?? "";
932
+ btn.addEventListener("click", async (e) => {
933
+ e.stopPropagation();
934
+ try {
935
+ await navigator.clipboard.writeText(serverUrl(btn));
936
+ } catch {
937
+ return;
938
+ }
939
+ if (label) label.textContent = "Copied!";
940
+ window.setTimeout(() => {
941
+ if (label) label.textContent = originalLabel;
942
+ }, 1500);
943
+ });
944
+ });
945
+ root.querySelectorAll<HTMLAnchorElement>("a[data-mcp-install]").forEach((link) => {
946
+ const url = mcpServerUrl(__WD_BASE__ ? window.location.origin + __WD_BASE__ : window.location.origin);
947
+ const name = link.dataset.mcpName ?? document.title;
948
+ link.href = link.dataset.mcpInstall === "cursor" ? cursorInstallLink(name, url) : vscodeInstallLink(name, url);
949
+ });
950
+ }
951
+ initMcpMenu(document);
952
+ document.addEventListener("astro:page-load", () => initMcpMenu(document));
953
+
954
+ // Show more/less toggle for ```js expandable code blocks - same
955
+ // build-time-emitted-button + client-wired-click pattern as the copy
956
+ // button above; codeBlockTransformer only adds this button when the
957
+ // fence's meta string contains the `expandable` keyword.
958
+ function initCodeExpandButtons(root: ParentNode) {
959
+ root.querySelectorAll<HTMLButtonElement>(".wd-code-expand-btn").forEach((btn) => {
960
+ if (btn.dataset.wdInit) return;
961
+ btn.dataset.wdInit = "true";
962
+ const block = btn.closest<HTMLElement>(".wd-code-expandable");
963
+ if (!block) return;
964
+ // A block no taller than the collapsed height has nothing to show
965
+ // more of: .wd-code-fits drops the fade and the button. Only when
966
+ // it can be measured - a block in a hidden CodeGroup tab or a
967
+ // closed accordion has no height yet, and keeps its button.
968
+ const pre = block.querySelector("pre");
969
+ // The collapsed height shows 12 lines and hides only the bottom
970
+ // padding, so that padding doesn't count against fitting.
971
+ const padBottom = pre ? parseFloat(getComputedStyle(pre).paddingBottom) || 0 : 0;
972
+ if (pre && pre.clientHeight > 0 && pre.scrollHeight - padBottom <= pre.clientHeight + 1) {
973
+ block.classList.add("wd-code-fits");
974
+ return;
975
+ }
976
+ btn.addEventListener("click", () => {
977
+ const expanded = block.classList.toggle("wd-code-expanded");
978
+ btn.textContent = expanded ? "Show less" : "Show more";
979
+ btn.setAttribute("aria-expanded", String(expanded));
980
+ // Collapsing a long block can leave the reader below it: bring
981
+ // it back into view.
982
+ if (!expanded) block.scrollIntoView({ block: "nearest" });
983
+ });
984
+ });
985
+ }
986
+ initCodeExpandButtons(document);
987
+ document.addEventListener("astro:page-load", () => initCodeExpandButtons(document));
988
+
989
+ // Renders ```mermaid fenced blocks - already reshaped at build time into
990
+ // plain <div class="mermaid">source text</div> containers (see
991
+ // rehypeMermaid in astro.config.mjs/src/lib/mermaid-rehype.js) - into
992
+ // actual SVG diagrams. Lazily imports the mermaid package itself, same
993
+ // reasoning as initSearch's Pagefind import above: most pages have no
994
+ // diagrams at all, no reason to ship/parse that bundle on every load.
995
+ let mermaidLoadPromise: Promise<typeof import("mermaid")> | null = null;
996
+ function ensureMermaid() {
997
+ if (!mermaidLoadPromise) mermaidLoadPromise = import("mermaid");
998
+ return mermaidLoadPromise;
999
+ }
1000
+
1001
+ // mermaid.run() replaces a block's contents with the rendered SVG,
1002
+ // destroying the original diagram source - stashed in a data attribute
1003
+ // the first time a block is seen (before it's ever rendered), so a
1004
+ // later re-render (see the wd:theme-change listener below - diagrams
1005
+ // are baked to static SVG at render time, so a theme change needs an
1006
+ // actual re-render, unlike Shiki code blocks which swap colors live via
1007
+ // CSS custom properties) has something to restore from.
1008
+ function stashMermaidSource(root: ParentNode) {
1009
+ root.querySelectorAll<HTMLElement>(".mermaid").forEach((el) => {
1010
+ if (el.dataset.mermaidSource === undefined) el.dataset.mermaidSource = el.textContent ?? "";
1011
+ });
1012
+ }
1013
+
1014
+ async function renderMermaid(root: ParentNode, theme: "light" | "dark") {
1015
+ const blocks = Array.from(root.querySelectorAll<HTMLElement>(".mermaid"));
1016
+ if (blocks.length === 0) return;
1017
+ const { default: mermaid } = await ensureMermaid();
1018
+ mermaid.initialize({ startOnLoad: false, theme: theme === "dark" ? "dark" : "default", securityLevel: "strict" });
1019
+ blocks.forEach((el) => {
1020
+ el.removeAttribute("data-processed"); // mermaid's own re-render guard - see run()'s docs
1021
+ el.innerHTML = el.dataset.mermaidSource ?? "";
1022
+ });
1023
+ // suppressErrors: a malformed diagram on one block shouldn't take
1024
+ // down every other diagram on the page - mermaid still renders a
1025
+ // per-block error SVG in place and logs details to the console.
1026
+ await mermaid.run({ nodes: blocks, suppressErrors: true });
1027
+ }
1028
+
1029
+ function initMermaid(root: ParentNode) {
1030
+ stashMermaidSource(root);
1031
+ if (!root.querySelector(".mermaid")) return;
1032
+ const theme = document.documentElement.dataset.theme === "dark" ? "dark" : "light";
1033
+ renderMermaid(root, theme);
1034
+ }
1035
+ initMermaid(document);
1036
+ document.addEventListener("astro:page-load", () => initMermaid(document));
1037
+ document.addEventListener("wd:theme-change", ((e: CustomEvent<{ theme: "light" | "dark" }>) => {
1038
+ renderMermaid(document, e.detail.theme);
1039
+ }) as EventListener);
1040
+
1041
+ // RequestExample/ResponseExample.astro's own docking behavior - on
1042
+ // desktop, moves their rendered .wd-example-panel(s) out of the normal
1043
+ // article flow and into .wd-toc-col (replacing whatever it would
1044
+ // otherwise show - the heading-based TableOfContents or
1045
+ // ApiReferencePanel, per those two components' own comment), matching
1046
+ // Mintlify's stated behavior for the components this was modeled on:
1047
+ // pinned in the sidebar on desktop, plain in-place code blocks below
1048
+ // 1150px (the exact breakpoint .wd-toc-col itself disappears at - see
1049
+ // base.css). This can't be done at build time: MDX compiles a page's
1050
+ // whole body into one content flow, with no way for a static render to
1051
+ // place part of that flow into a *different* column's own slot output
1052
+ // - a client-side move after the fact is the only way to get this
1053
+ // content into a sibling column's subtree at all.
1054
+ function initExamplePanels(root: ParentNode) {
1055
+ const tocCol = document.querySelector<HTMLElement>(".wd-toc-col");
1056
+ if (!tocCol) return; // no toc column on this page (mode !== 'default') - nothing to dock into
1057
+
1058
+ // Top-level panels only: Mintlify's <Panel> (Panel.astro) is itself a
1059
+ // .wd-example-panel, and a RequestExample/ResponseExample inside it
1060
+ // moves with it rather than on its own.
1061
+ const panels = Array.from(root.querySelectorAll<HTMLElement>(".wd-example-panel")).filter(
1062
+ (panel) => !panel.parentElement?.closest(".wd-example-panel"),
1063
+ );
1064
+ if (panels.length === 0) return;
1065
+ if (tocCol.dataset.wdExampleInit) return;
1066
+ tocCol.dataset.wdExampleInit = "true";
1067
+
1068
+ // Response always docks below Request regardless of source order,
1069
+ // matching Mintlify's own stated behavior for these two components.
1070
+ panels.sort((a, b) => {
1071
+ const rank = (el: HTMLElement) => (el.classList.contains("wd-request-example") ? 0 : 1);
1072
+ return rank(a) - rank(b);
1073
+ });
1074
+
1075
+ // A comment node marks each panel's original in-flow position, so
1076
+ // undock() (a desktop -> mobile resize, or simply no matching media
1077
+ // query at all) can put it back exactly where the article's own
1078
+ // content expects it, rather than leaving a permanent gap.
1079
+ const anchors = panels.map((panel) => {
1080
+ const anchor = document.createComment("wd-example-anchor");
1081
+ panel.before(anchor);
1082
+ return anchor;
1083
+ });
1084
+
1085
+ let host = tocCol.querySelector<HTMLElement>(".wd-example-host");
1086
+ if (!host) {
1087
+ host = document.createElement("div");
1088
+ host.className = "wd-example-host";
1089
+ tocCol.prepend(host);
1090
+ }
1091
+ const dockedHost = host;
1092
+
1093
+ // Whatever .wd-toc-col would otherwise render (TableOfContents' own
1094
+ // <nav class="wd-toc">, or ApiReferencePanel's own markup) - hidden
1095
+ // while panels are docked rather than removed, so undock() has
1096
+ // something to restore instead of needing to re-render it.
1097
+ const existingTocContent = Array.from(tocCol.children).filter((el) => el !== dockedHost) as HTMLElement[];
1098
+
1099
+ function dock() {
1100
+ existingTocContent.forEach((el) => (el.style.display = "none"));
1101
+ dockedHost.hidden = false;
1102
+ panels.forEach((panel) => dockedHost.appendChild(panel));
1103
+ }
1104
+ function undock() {
1105
+ dockedHost.hidden = true;
1106
+ existingTocContent.forEach((el) => (el.style.display = ""));
1107
+ panels.forEach((panel, i) => anchors[i].after(panel));
1108
+ }
1109
+ const desktopQuery = window.matchMedia("(min-width: 1151px)");
1110
+ const sync = () => (desktopQuery.matches ? dock() : undock());
1111
+ sync();
1112
+ desktopQuery.addEventListener("change", sync);
1113
+ }
1114
+ initExamplePanels(document);
1115
+ document.addEventListener("astro:page-load", () => initExamplePanels(document));
1116
+ </script>
1117
+
1118
+ <style>
1119
+ .wd-article {
1120
+ max-width: 900px;
1121
+ margin: 0 auto;
1122
+ /* Top padding matches Sidebar.astro's .wd-sidebar and
1123
+ TableOfContents.astro's .wd-toc exactly (both 1.5rem) - all three
1124
+ are siblings in the same .wd-shell row with no padding of their
1125
+ own on .wd-main-col in between, so this is what actually lines up
1126
+ the article's top edge with the sidebar/TOC's first item instead
1127
+ of starting visibly lower than both. */
1128
+ padding: 1.5rem 1.5rem 4rem;
1129
+ }
1130
+ /* frontmatter `mode: wide` - the table of contents column is gone (see
1131
+ BaseLayout.astro), so the article itself gets more room too, rather
1132
+ than just recentering the same 760px column into now-empty space. */
1133
+ .wd-article-wide {
1134
+ max-width: 1040px;
1135
+ }
1136
+ /* frontmatter `mode: custom` - no prose width/padding at all, no
1137
+ max-width, no centering: a hand-built landing page controls its own
1138
+ layout completely, full-bleed if it wants to. */
1139
+ .wd-canvas {
1140
+ width: 100%;
1141
+ }
1142
+ /* Wraps the auto-rendered <h1> together with CopyPageMenu (only
1143
+ rendered when writedocs.json's `contextMenu` isn't off - see
1144
+ showCopyPageMenu above) so the two sit on one row, menu pinned to
1145
+ the right. Always present (even with no menu) rather than only
1146
+ wrapping the <h1> conditionally, so the <h1>'s own top/bottom
1147
+ spacing comes from exactly one place regardless of whether the menu
1148
+ renders - flex items don't margin-collapse with their container the
1149
+ way a bare <h1> would with .wd-article, so that margin is
1150
+ reset/reapplied here instead of relying on the browser's default
1151
+ heading margin still doing the right thing once it's no longer a
1152
+ direct .wd-article child. */
1153
+ .wd-article-header {
1154
+ display: flex;
1155
+ flex-wrap: wrap;
1156
+ align-items: center;
1157
+ justify-content: space-between;
1158
+ gap: 0.75rem 1rem;
1159
+ margin: 0 0 1rem;
1160
+ }
1161
+ .wd-article-header h1 {
1162
+ margin: 0;
1163
+ /* A word longer than the whole line (a long product name on a phone)
1164
+ breaks rather than pushing the page wider than the screen. */
1165
+ overflow-wrap: break-word;
1166
+ }
1167
+ /* The title takes the room the menu leaves. Its basis is 0, so the row
1168
+ only wraps when its longest word and the menu can't share a line - on
1169
+ a desktop, a long title still wraps beside the menu; on a phone, a long
1170
+ word sends the menu below the title instead of off the screen. */
1171
+ .wd-article-header > h1,
1172
+ .wd-article-header > .wd-article-title {
1173
+ flex: 1 1 0;
1174
+ }
1175
+ /* Frontmatter `deprecated: true` (Mintlify's) - same amber as the
1176
+ sidebar's own deprecated tag (NavTree.astro) and Parameter's
1177
+ deprecated badge. */
1178
+ .wd-article-title {
1179
+ display: flex;
1180
+ align-items: center;
1181
+ flex-wrap: wrap;
1182
+ gap: 0.6rem;
1183
+ }
1184
+ .wd-deprecated-badge {
1185
+ display: inline-block;
1186
+ padding: 0.15rem 0.55rem;
1187
+ border-radius: 999px;
1188
+ font-size: 0.8rem;
1189
+ font-weight: 700;
1190
+ color: #d97706;
1191
+ background: color-mix(in srgb, #d97706 15%, transparent);
1192
+ }
1193
+ .wd-prevnext {
1194
+ display: flex;
1195
+ justify-content: space-between;
1196
+ margin-top: 3rem;
1197
+ padding-top: 1.5rem;
1198
+ border-top: 1px solid var(--wd-border);
1199
+ gap: 1rem;
1200
+ }
1201
+ /* Two side-by-side cards, each taking up to half the row - flex: 1 1
1202
+ 0 rather than a fixed 50% so a single remaining card (first page:
1203
+ only next, last page: only prev) grows to fill the width instead
1204
+ of leaving an empty gap next to it. */
1205
+ .wd-prevnext-card {
1206
+ display: flex;
1207
+ flex: 1 1 0;
1208
+ min-width: 0;
1209
+ flex-direction: column;
1210
+ gap: 0.1rem;
1211
+ padding: 0.75rem 1.1rem;
1212
+ border: 1px solid var(--wd-border);
1213
+ border-radius: 0.75rem;
1214
+ text-decoration: none;
1215
+ color: inherit;
1216
+ transition:
1217
+ border-color 0.15s ease,
1218
+ box-shadow 0.15s ease;
1219
+ }
1220
+ /* Both cards are identical at rest - the accent border/glow in the
1221
+ reference screenshot is that card's :hover state, not a permanent
1222
+ treatment on Next, so both wd-prevnext-prev and wd-prevnext-next
1223
+ share this one hover rule instead of Next getting its own always-on
1224
+ copy. Built from --wd-primary via color-mix() rather than a flat
1225
+ hardcoded color, so it stays correct under any theme's own accent. */
1226
+ .wd-prevnext-card:hover {
1227
+ border-color: var(--wd-primary);
1228
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--wd-primary) 10%, transparent);
1229
+ }
1230
+ .wd-prevnext-row {
1231
+ display: flex;
1232
+ align-items: center;
1233
+ justify-content: space-between;
1234
+ gap: 0.5rem;
1235
+ color: var(--wd-text-muted);
1236
+ font-size: 0.75rem;
1237
+ }
1238
+ .wd-prevnext-icon {
1239
+ flex-shrink: 0;
1240
+ color: var(--wd-text-muted);
1241
+ transition: color 0.15s ease;
1242
+ }
1243
+ .wd-prevnext-title {
1244
+ font-weight: 600;
1245
+ font-size: 0.85rem;
1246
+ color: var(--wd-heading);
1247
+ white-space: nowrap;
1248
+ overflow: hidden;
1249
+ text-overflow: ellipsis;
1250
+ transition: color 0.15s ease;
1251
+ }
1252
+ /* Previous's title sits at the same end of the card its own
1253
+ "Previous" label already does (right-aligned, next to the arrow's
1254
+ fixed spot on the left) - Next's title stays left-aligned, at the
1255
+ same end its own "Next" label sits. Keeps each card's two rows
1256
+ reading as one consistent left/right-anchored column instead of
1257
+ the title always defaulting to the left regardless of which side
1258
+ its card's own label/arrow occupy. */
1259
+ .wd-prevnext-prev .wd-prevnext-title {
1260
+ text-align: right;
1261
+ }
1262
+ /* Icon and title pick up the accent color on hover - the
1263
+ "Next"/"Previous" label itself stays muted even then, since it's a
1264
+ plain UI affordance rather than the actual content being pointed
1265
+ to. */
1266
+ .wd-prevnext-card:hover .wd-prevnext-icon,
1267
+ .wd-prevnext-card:hover .wd-prevnext-title {
1268
+ color: var(--wd-primary);
1269
+ }
1270
+ @media (width <= 640px) {
1271
+ .wd-prevnext {
1272
+ flex-direction: column;
1273
+ }
1274
+ }
1275
+ </style>
1276
+
1277
+ <style is:global>
1278
+ /*
1279
+ * These target direct children of .wd-article (or, for inline marks,
1280
+ * specific prose containers) rather than bare tag selectors. MDX
1281
+ * component internals (Card titles/links, prev/next nav links) also
1282
+ * live inside .wd-article but nested deeper - a bare ".wd-article h3"
1283
+ * or ".wd-article a" would win the specificity tie against those
1284
+ * components' own scoped styles and visibly break them (oversized
1285
+ * card titles, underlined cards, underlined prev/next links). Real
1286
+ * MDX content (headings, paragraphs, lists, etc.) renders as flat
1287
+ * direct children of .wd-article, so the ">" combinator is enough to
1288
+ * separate "actual content" from "component chrome" without needing
1289
+ * per-component :not() exceptions.
1290
+ */
1291
+ /* --wd-topbar-offset is set by initTopbarOffset() (src/scripts/
1292
+ topbar-offset.ts) to the sticky topbar's real measured height - see
1293
+ its own file comment for why a fixed 5rem (this var()'s own
1294
+ fallback, for the instant before that script's first measurement)
1295
+ isn't enough once a site's topbar grows a second row. Without this,
1296
+ jumping straight to a #heading link (a hard load, or clicking one of
1297
+ the .wd-heading-anchor links below) lands the heading partly hidden
1298
+ under the sticky topbar. */
1299
+ .wd-article > h2 {
1300
+ font-size: 1.5rem;
1301
+ margin: 2.75rem 0 1rem;
1302
+ padding-top: 0.25rem;
1303
+ scroll-margin-top: var(--wd-topbar-offset, 5rem);
1304
+ }
1305
+ .wd-article > h3 {
1306
+ font-size: 1.2rem;
1307
+ margin: 2rem 0 0.75rem;
1308
+ scroll-margin-top: var(--wd-topbar-offset, 5rem);
1309
+ }
1310
+ .wd-article > h4 {
1311
+ font-size: 1rem;
1312
+ margin: 1.5rem 0 0.5rem;
1313
+ scroll-margin-top: var(--wd-topbar-offset, 5rem);
1314
+ }
1315
+ .wd-article > h2:first-child,
1316
+ .wd-article > h3:first-child {
1317
+ margin-top: 0;
1318
+ }
1319
+ .wd-article > p {
1320
+ margin: 0.9rem 0;
1321
+ }
1322
+ .wd-article > ul,
1323
+ .wd-article > ol {
1324
+ margin: 0.9rem 0;
1325
+ padding-left: 1.4rem;
1326
+ }
1327
+ .wd-article li {
1328
+ margin: 0.35rem 0;
1329
+ }
1330
+ .wd-article li > ul,
1331
+ .wd-article li > ol {
1332
+ margin: 0.35rem 0;
1333
+ }
1334
+ .wd-article > blockquote {
1335
+ margin: 1.25rem 0;
1336
+ padding: 0.1rem 1rem;
1337
+ border-left: 3px solid var(--wd-primary);
1338
+ background: var(--wd-surface);
1339
+ border-radius: 0 0.4rem 0.4rem 0;
1340
+ color: var(--wd-text-muted);
1341
+ }
1342
+ .wd-article blockquote p {
1343
+ margin: 0.7rem 0;
1344
+ }
1345
+ .wd-article > table {
1346
+ width: 100%;
1347
+ border-collapse: collapse;
1348
+ margin: 1.25rem 0;
1349
+ font-size: 0.9rem;
1350
+ }
1351
+ .wd-article th,
1352
+ .wd-article td {
1353
+ text-align: left;
1354
+ padding: 0.55rem 0.75rem;
1355
+ border-bottom: 1px solid var(--wd-border);
1356
+ vertical-align: top;
1357
+ }
1358
+ .wd-article th {
1359
+ color: var(--wd-text-muted);
1360
+ font-weight: 600;
1361
+ font-size: 0.8rem;
1362
+ text-transform: uppercase;
1363
+ letter-spacing: 0.03em;
1364
+ }
1365
+ .wd-article > hr {
1366
+ border: none;
1367
+ border-top: 1px solid var(--wd-border);
1368
+ margin: 2.5rem 0;
1369
+ }
1370
+ /* Fenced (```) code blocks - codeBlockTransformer
1371
+ (src/lib/shiki-code-block.js) wraps every one's <pre> in this
1372
+ .wd-code-block div at build time (plus an optional .wd-code-title
1373
+ bar, and the copy/expand buttons - see below). The card-like chrome
1374
+ (border/radius/background) lives on the wrapper rather than the
1375
+ <pre> itself so a title bar, when present, can sit flush above it
1376
+ inside the same box; Astro's Shiki pipeline (dual light/dark themes
1377
+ configured in astro.config.mjs) already supplies the <pre>'s own
1378
+ background/text colors via inline styles. Matches both a standalone
1379
+ block (direct child of .wd-article) and one nested inside
1380
+ <CodeGroup> (which re-targets the margin/radius itself via its own
1381
+ more specific `.wd-codegroup > .wd-code-block` rule in
1382
+ CodeGroup.astro).
1383
+ The layout follows Mintlify's: a frame (the wrapper - border, surface
1384
+ background, a 0.125rem inset) holding the title bar, and the code in
1385
+ its own rounded panel inside it (the <pre>, in the code theme's
1386
+ background). --wd-code-pad-x is the panel's side padding: the
1387
+ highlighted and diff lines below stretch past it by the same amount
1388
+ to reach the panel's edges. */
1389
+ .wd-code-block {
1390
+ --wd-code-pad-x: 1rem;
1391
+ position: relative;
1392
+ margin: 1.25rem 0 2rem;
1393
+ padding: 0.125rem;
1394
+ border: 1px solid var(--wd-border);
1395
+ border-radius: 1rem;
1396
+ background: var(--wd-surface);
1397
+ }
1398
+ .wd-article pre.astro-code {
1399
+ margin: 0;
1400
+ padding: 0.75rem var(--wd-code-pad-x);
1401
+ border: none;
1402
+ border-radius: 0.875rem;
1403
+ font-size: 0.875rem;
1404
+ line-height: 1.5rem;
1405
+ }
1406
+ /* On the frame, above the panel - room on the right for the copy
1407
+ button, which moves into this bar when there is one (below). */
1408
+ .wd-code-title {
1409
+ padding: 0.25rem 2.75rem 0.25rem var(--wd-code-pad-x);
1410
+ font-size: 0.75rem;
1411
+ font-weight: 500;
1412
+ line-height: 1.5rem;
1413
+ color: var(--wd-text);
1414
+ white-space: nowrap;
1415
+ overflow: hidden;
1416
+ text-overflow: ellipsis;
1417
+ }
1418
+ /* A fence's `icon="..."` (shiki-code-block.js) - the icon's own SVG
1419
+ arrives as a data URL in --wd-code-icon and is used as a mask, so it
1420
+ paints in the title's text color instead of the SVG's own fill. */
1421
+ .wd-code-title-icon {
1422
+ display: inline-block;
1423
+ width: 1em;
1424
+ height: 1em;
1425
+ margin-right: 0.45rem;
1426
+ vertical-align: -0.125em;
1427
+ background: currentColor;
1428
+ -webkit-mask: var(--wd-code-icon) center / contain no-repeat;
1429
+ mask: var(--wd-code-icon) center / contain no-repeat;
1430
+ }
1431
+ /* Without a title bar, the copy button sits in the panel's top-right
1432
+ corner and shows on hover or keyboard focus. */
1433
+ .wd-code-copy-btn {
1434
+ position: absolute;
1435
+ top: 0.625rem;
1436
+ right: 0.625rem;
1437
+ z-index: 1;
1438
+ display: inline-flex;
1439
+ align-items: center;
1440
+ justify-content: center;
1441
+ width: 1.75rem;
1442
+ height: 1.75rem;
1443
+ padding: 0;
1444
+ border-radius: 0.5rem;
1445
+ border: 1px solid var(--wd-border);
1446
+ background: var(--wd-surface);
1447
+ color: var(--wd-text-muted);
1448
+ font-size: 0.9rem;
1449
+ line-height: 1;
1450
+ cursor: pointer;
1451
+ opacity: 0;
1452
+ transition:
1453
+ opacity 0.15s ease,
1454
+ color 0.15s ease,
1455
+ background 0.15s ease,
1456
+ border-color 0.15s ease;
1457
+ }
1458
+ .wd-code-block:hover .wd-code-copy-btn,
1459
+ .wd-code-copy-btn:focus-visible {
1460
+ opacity: 1;
1461
+ }
1462
+ .wd-code-copy-btn:hover {
1463
+ color: var(--wd-text);
1464
+ background: var(--wd-background);
1465
+ }
1466
+ /* With a title bar, it's an always-visible icon at the bar's right end,
1467
+ like Mintlify's: centered in the 2rem bar, inside the frame's inset. */
1468
+ .wd-code-title ~ .wd-code-copy-btn {
1469
+ top: 0.375rem;
1470
+ right: 0.5rem;
1471
+ width: 1.5rem;
1472
+ height: 1.5rem;
1473
+ border-color: transparent;
1474
+ background: transparent;
1475
+ opacity: 1;
1476
+ }
1477
+ .wd-code-title ~ .wd-code-copy-btn:hover {
1478
+ background: color-mix(in srgb, var(--wd-text) 8%, transparent);
1479
+ }
1480
+ .wd-code-copy-btn.wd-code-copied {
1481
+ opacity: 1;
1482
+ color: #16a34a;
1483
+ border-color: #16a34a;
1484
+ }
1485
+ /* ```js wrap - opts a single block into wrapping long lines instead
1486
+ of horizontal-scrolling (the default). */
1487
+ .wd-code-wrap pre.astro-code,
1488
+ .wd-code-wrap pre.astro-code code {
1489
+ white-space: pre-wrap;
1490
+ word-break: break-word;
1491
+ overflow-x: hidden;
1492
+ }
1493
+ /* ```js lines (or showLineNumbers) - a CSS-counter gutter, no markup
1494
+ needed beyond a class since every line is already its own .line
1495
+ span. The column is --wd-code-digits characters wide (set on the
1496
+ wrapper by shiki-code-block.js from the line count), so the numbers
1497
+ start at the panel's padding and stay right-aligned past nine lines. */
1498
+ .wd-code-lines pre.astro-code code {
1499
+ counter-reset: wd-code-line;
1500
+ }
1501
+ .wd-code-lines pre.astro-code .line {
1502
+ counter-increment: wd-code-line;
1503
+ }
1504
+ .wd-code-lines pre.astro-code .line::before {
1505
+ content: counter(wd-code-line);
1506
+ display: inline-block;
1507
+ width: calc(var(--wd-code-digits, 2) * 1ch);
1508
+ margin-right: 1.25rem;
1509
+ text-align: right;
1510
+ color: var(--wd-text-muted);
1511
+ user-select: none;
1512
+ }
1513
+ /* ```js expandable - collapses to its first 12 lines (plus the panel's
1514
+ top padding) with a "Show more" button below; toggled via
1515
+ .wd-code-expanded, added by the click handler in the <script> block
1516
+ below. A block that already fits gets .wd-code-fits from the same
1517
+ script instead, and is never collapsed: no fade, no button. */
1518
+ .wd-code-expandable:not(.wd-code-expanded, .wd-code-fits) pre.astro-code {
1519
+ max-height: calc(12 * 1.5rem + 0.75rem);
1520
+ overflow-y: hidden;
1521
+ }
1522
+ /* The fade over the last visible lines: a strip at the end of the code,
1523
+ stuck to the bottom of the clipped panel (and to its left edge, if
1524
+ the block is scrolled sideways), three lines tall and solid over the
1525
+ last one, so no line shows cut in half. It's the panel's own background -
1526
+ `inherit` takes the <pre>'s computed color, the dark theme's in dark
1527
+ mode - masked from transparent to solid, so it fades into whatever
1528
+ code theme the site uses. */
1529
+ .wd-code-expandable:not(.wd-code-expanded, .wd-code-fits) pre.astro-code::after {
1530
+ content: "";
1531
+ position: sticky;
1532
+ /* Sticky offsets count from inside the <pre>'s padding: minus the
1533
+ padding puts the strip on the panel's edges, over the padding too. */
1534
+ bottom: -0.75rem;
1535
+ left: calc(-1 * var(--wd-code-pad-x));
1536
+ display: block;
1537
+ width: calc(100% + 2 * var(--wd-code-pad-x));
1538
+ height: 4.5rem;
1539
+ margin: -4.5rem calc(-1 * var(--wd-code-pad-x)) 0;
1540
+ background-color: inherit;
1541
+ -webkit-mask-image: linear-gradient(to bottom, transparent, #000 70%);
1542
+ mask-image: linear-gradient(to bottom, transparent, #000 70%);
1543
+ pointer-events: none;
1544
+ }
1545
+ .wd-code-fits .wd-code-expand-btn {
1546
+ display: none;
1547
+ }
1548
+ /* Below the panel, on the frame, with a chevron that turns up once
1549
+ the block is open. */
1550
+ .wd-code-expand-btn {
1551
+ display: flex;
1552
+ align-items: center;
1553
+ justify-content: center;
1554
+ gap: 0.5rem;
1555
+ width: 100%;
1556
+ padding: 0.25rem;
1557
+ border: none;
1558
+ border-radius: 0 0 0.875rem 0.875rem;
1559
+ background: transparent;
1560
+ color: var(--wd-text-muted);
1561
+ font-family: inherit;
1562
+ font-size: 0.75rem;
1563
+ font-weight: 500;
1564
+ line-height: 1.5rem;
1565
+ cursor: pointer;
1566
+ transition:
1567
+ color 0.15s ease,
1568
+ background 0.15s ease;
1569
+ }
1570
+ .wd-code-expand-btn::after {
1571
+ content: "";
1572
+ width: 0.375rem;
1573
+ height: 0.375rem;
1574
+ border-right: 1.5px solid currentColor;
1575
+ border-bottom: 1.5px solid currentColor;
1576
+ transform: translateY(-0.1rem) rotate(45deg);
1577
+ transition: transform 0.15s ease;
1578
+ }
1579
+ .wd-code-expanded .wd-code-expand-btn::after {
1580
+ transform: translateY(0.1rem) rotate(-135deg);
1581
+ }
1582
+ .wd-code-expand-btn:hover {
1583
+ color: var(--wd-text);
1584
+ background: color-mix(in srgb, var(--wd-text) 6%, transparent);
1585
+ }
1586
+ /* Line/word annotation classes added by the official
1587
+ @shikijs/transformers transformers configured alongside
1588
+ codeBlockTransformer in astro.config.mjs:
1589
+ .line.highlighted - transformerMetaHighlight
1590
+ (```js {1,3-5}) and
1591
+ transformerNotationHighlight
1592
+ (// [!code highlight]/[!code hl])
1593
+ .line.diff.add / .diff.remove - transformerNotationDiff
1594
+ (// [!code ++] / // [!code --])
1595
+ .line.error / .warning / .info - transformerNotationErrorLevel
1596
+ (// [!code error]/[!code warning])
1597
+ (also carries .highlighted)
1598
+ pre.has-focused, .line.focused - transformerNotationFocus
1599
+ (// [!code focus])
1600
+ .highlighted-word - transformerMetaWordHighlight
1601
+ (```js /someWord/) and
1602
+ transformerNotationWordHighlight
1603
+ (// [!code word:someWord])
1604
+ Every .line needs display:inline-block + full width for its
1605
+ highlight background to stretch edge-to-edge (by default a <span>
1606
+ only extends as wide as its own text) - harmless for plain lines,
1607
+ since inline-block with no other styling renders identically to
1608
+ the browser's normal inline flow here. */
1609
+ .astro-code .line {
1610
+ display: inline-block;
1611
+ width: 100%;
1612
+ }
1613
+ .astro-code .line.highlighted {
1614
+ background: color-mix(in srgb, var(--wd-primary) 12%, transparent);
1615
+ margin: 0 calc(-1 * var(--wd-code-pad-x, 1rem));
1616
+ padding: 0 var(--wd-code-pad-x, 1rem);
1617
+ width: calc(100% + 2 * var(--wd-code-pad-x, 1rem));
1618
+ }
1619
+ .astro-code .line.diff {
1620
+ margin: 0 calc(-1 * var(--wd-code-pad-x, 1rem));
1621
+ padding: 0 var(--wd-code-pad-x, 1rem);
1622
+ width: calc(100% + 2 * var(--wd-code-pad-x, 1rem));
1623
+ position: relative;
1624
+ }
1625
+ .astro-code .line.diff.add {
1626
+ background: color-mix(in srgb, #16a34a 15%, transparent);
1627
+ }
1628
+ .astro-code .line.diff.remove {
1629
+ background: color-mix(in srgb, #dc2626 15%, transparent);
1630
+ opacity: 0.85;
1631
+ }
1632
+ .astro-code .line.diff.add::before,
1633
+ .astro-code .line.diff.remove::before {
1634
+ position: absolute;
1635
+ left: 0.3rem;
1636
+ font-weight: 700;
1637
+ }
1638
+ .astro-code .line.diff.add::before {
1639
+ content: "+";
1640
+ color: #16a34a;
1641
+ }
1642
+ .astro-code .line.diff.remove::before {
1643
+ content: "-";
1644
+ color: #dc2626;
1645
+ }
1646
+ .astro-code .line.error {
1647
+ background: color-mix(in srgb, #dc2626 15%, transparent);
1648
+ }
1649
+ .astro-code .line.warning {
1650
+ background: color-mix(in srgb, #d97706 15%, transparent);
1651
+ }
1652
+ .astro-code .line.info {
1653
+ background: color-mix(in srgb, #2563eb 12%, transparent);
1654
+ }
1655
+ pre.astro-code.has-focused .line {
1656
+ opacity: 0.45;
1657
+ filter: blur(0.3px);
1658
+ transition:
1659
+ opacity 0.2s ease,
1660
+ filter 0.2s ease;
1661
+ }
1662
+ pre.astro-code.has-focused .line.focused {
1663
+ opacity: 1;
1664
+ filter: none;
1665
+ }
1666
+ pre.astro-code.has-focused:hover .line {
1667
+ opacity: 1;
1668
+ filter: none;
1669
+ }
1670
+ .astro-code .highlighted-word {
1671
+ background: color-mix(in srgb, var(--wd-primary) 20%, transparent);
1672
+ border-radius: 0.25rem;
1673
+ padding: 0.05rem 0.2rem;
1674
+ margin: -0.05rem -0.15rem;
1675
+ }
1676
+ .wd-article img {
1677
+ max-width: 100%;
1678
+ border-radius: 0.5rem;
1679
+ border: 1px solid var(--wd-border);
1680
+ }
1681
+ /* ```mermaid fenced blocks (rehypeMermaid in astro.config.mjs reshapes
1682
+ them into this plain <div class="mermaid"> container at build time -
1683
+ see mermaid-rehype.js) - mermaid.js (initMermaid() below) replaces
1684
+ the raw source text with a rendered <svg> in place, client-side.
1685
+ overflow-x: auto rather than shrinking the diagram, since a wide
1686
+ flowchart squeezed into the article's ~760px column becomes
1687
+ unreadable; centering only kicks in once the svg fits, via the
1688
+ inline-block + text-align combo below. */
1689
+ .wd-article > div.mermaid {
1690
+ margin: 1.25rem 0;
1691
+ padding: 1rem;
1692
+ overflow-x: auto;
1693
+ text-align: center;
1694
+ background: var(--wd-surface);
1695
+ border: 1px solid var(--wd-border);
1696
+ border-radius: 0.55rem;
1697
+ }
1698
+ .wd-article > div.mermaid svg {
1699
+ display: inline-block;
1700
+ max-width: 100%;
1701
+ }
1702
+ /* Only style links inside actual prose containers - excludes Card
1703
+ (which is itself an <a>) and the prev/next nav links. */
1704
+ .wd-article p a,
1705
+ .wd-article li a,
1706
+ .wd-article td a,
1707
+ .wd-article blockquote a {
1708
+ text-decoration: underline;
1709
+ text-decoration-color: color-mix(in srgb, var(--wd-primary) 40%, transparent);
1710
+ text-underline-offset: 2px;
1711
+ }
1712
+ .wd-article strong {
1713
+ font-weight: 600;
1714
+ }
1715
+ .wd-article > h2 a[href^="#"],
1716
+ .wd-article > h3 a[href^="#"],
1717
+ .wd-article > h4 a[href^="#"] {
1718
+ text-decoration: none;
1719
+ }
1720
+ .wd-heading-anchor {
1721
+ display: inline-block;
1722
+ margin-left: 0.5rem;
1723
+ color: var(--wd-text-muted);
1724
+ opacity: 0;
1725
+ text-decoration: none;
1726
+ font-weight: 400;
1727
+ transition: opacity 0.1s ease;
1728
+ }
1729
+ .wd-article > h2:hover .wd-heading-anchor,
1730
+ .wd-article > h3:hover .wd-heading-anchor,
1731
+ .wd-article > h4:hover .wd-heading-anchor,
1732
+ .wd-heading-anchor:focus {
1733
+ opacity: 1;
1734
+ }
1735
+ /* RequestExample/ResponseExample.astro's own panels, and the
1736
+ .wd-toc-col host initExamplePanels() (see the <script> above) docks
1737
+ them into on desktop - is:global (this whole style block already
1738
+ is) since .wd-toc-col itself is BaseLayout.astro's own markup, a
1739
+ completely different component than this one. Widens .wd-toc-col
1740
+ itself only while it actually contains a non-empty host - the same
1741
+ :has() technique ApiReferencePanel.astro's own identical comment
1742
+ already uses to widen it for its own markup, so a page with neither
1743
+ feature keeps the narrower 230px default from base.css. */
1744
+ .wd-toc-col:has(.wd-example-host:not(:empty)) {
1745
+ width: 340px;
1746
+ }
1747
+ .wd-example-host {
1748
+ position: sticky;
1749
+ top: var(--wd-topbar-offset, 5rem);
1750
+ max-height: calc(100vh - var(--wd-topbar-offset, 5rem));
1751
+ overflow-y: auto;
1752
+ padding: 1.5rem 0 1.5rem 0.5rem;
1753
+ }
1754
+ /* Spacing between multiple docked panels (e.g. Request above
1755
+ Response) is this wrapper's own job only once docked - inline
1756
+ (mobile, no-toc-column, or not-yet-docked), the wrapped
1757
+ .wd-codegroup's own default margin already spaces stacked panels
1758
+ out correctly, so adding a second margin here unscoped would just
1759
+ double it up. */
1760
+ .wd-example-host .wd-example-panel {
1761
+ margin-bottom: 1.25rem;
1762
+ }
1763
+ .wd-example-host .wd-example-panel:last-child {
1764
+ margin-bottom: 0;
1765
+ }
1766
+ .wd-example-host .wd-codegroup {
1767
+ margin: 0;
1768
+ }
1769
+
1770
+ .wd-example-host .astro-code {
1771
+ margin: 0;
1772
+ }
1773
+ </style>