@writedocs/generator 0.13.4 → 0.13.5

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