@writedocs/generator 0.13.5 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/astro.config.mjs +31 -69
  2. package/bin/writedocs.js +4 -1
  3. package/package.json +4 -2
  4. package/packages/components/package.json +53 -0
  5. package/{src → packages/components/src}/components/Accordion.astro +2 -2
  6. package/{src → packages/components/src}/components/AppIcon.astro +3 -3
  7. package/{src → packages/components/src}/components/Callout.astro +3 -3
  8. package/{src → packages/components/src}/components/CodeBlock.astro +8 -27
  9. package/{src → packages/components/src}/components/CodeGroup.astro +3 -3
  10. package/{src → packages/components/src}/components/Image.astro +7 -9
  11. package/{src → packages/components/src}/components/compound.ts +1 -1
  12. package/packages/components/src/host.js +24 -0
  13. package/packages/components/src/index.ts +59 -0
  14. package/packages/components/src/integration.js +151 -0
  15. package/packages/components/src/lib/base-path.js +39 -0
  16. package/{src → packages/components/src}/lib/code-line-numbers.js +1 -1
  17. package/packages/components/src/lib/code-transformers.js +45 -0
  18. package/{src → packages/components/src}/lib/icons.js +13 -7
  19. package/{src → packages/components/src}/lib/shiki-code-block.js +9 -9
  20. package/{src → packages/components/src}/lib/site-base.ts +9 -6
  21. package/packages/components/src/scripts/code-block.ts +62 -0
  22. package/packages/components/src/styles/components.css +373 -0
  23. package/packages/components/src/styles/theme.css +63 -0
  24. package/src/cli/build.js +23 -3
  25. package/src/cli/dev.js +2 -1
  26. package/src/cli/generate-api-pages.js +9 -7
  27. package/src/cli/page-list-watch.js +4 -2
  28. package/src/cli/run-astro.js +2 -2
  29. package/src/components/ApiPlayground.astro +2 -2
  30. package/src/components/ApiSchemaField.astro +1 -1
  31. package/src/components/CopyPageMenu.astro +2 -2
  32. package/src/content.config.ts +16 -0
  33. package/src/icons/README.md +1 -1
  34. package/src/layout/BaseLayout.astro +7 -2
  35. package/src/layout/components/AnalyticsScripts.astro +2 -2
  36. package/src/layout/components/Breadcrumbs.astro +1 -1
  37. package/src/layout/components/ConsentBanner.astro +1 -1
  38. package/src/layout/components/MobileMenu.astro +2 -2
  39. package/src/layout/components/NavTree.astro +16 -2
  40. package/src/layout/components/Sidebar.astro +2 -2
  41. package/src/layout/components/SiteFooter.astro +2 -2
  42. package/src/layout/components/TopBar.astro +2 -2
  43. package/src/layout/styles/base.css +4 -37
  44. package/src/lib/a11y-check.js +1 -1
  45. package/src/lib/base-path.js +4 -25
  46. package/src/lib/color.js +1 -1
  47. package/src/lib/components-host.ts +21 -0
  48. package/src/lib/config-file.js +1 -1
  49. package/src/lib/config-schema.js +12 -1
  50. package/src/lib/config-schema.ts +14 -0
  51. package/src/lib/config.ts +22 -6
  52. package/src/lib/content-check.js +6 -3
  53. package/src/lib/drafts.js +186 -0
  54. package/src/lib/link-check.js +13 -4
  55. package/src/lib/mdx-inject-builtins.js +2 -2
  56. package/src/lib/mdx-inline-react.js +1 -1
  57. package/src/lib/mdx-title-anchor-ids.js +2 -2
  58. package/src/lib/mdx-unknown-components.js +1 -1
  59. package/src/lib/mintlify-convert.js +2 -2
  60. package/src/lib/openapi-reload-integration.js +1 -1
  61. package/src/lib/pages.js +41 -7
  62. package/src/lib/project-files-integration.js +1 -1
  63. package/src/lib/rehype-base-path.js +1 -1
  64. package/src/lib/seo-tags.js +3 -1
  65. package/src/lib/writedocs-legacy-convert.js +1 -1
  66. package/src/pages/404.astro +1 -1
  67. package/src/pages/[...slug].astro +65 -417
  68. package/src/components/index.ts +0 -62
  69. /package/{src → packages/components/src}/components/AccordionGroup.astro +0 -0
  70. /package/{src → packages/components/src}/components/Badge.astro +0 -0
  71. /package/{src → packages/components/src}/components/Card.astro +0 -0
  72. /package/{src → packages/components/src}/components/CardGroup.astro +0 -0
  73. /package/{src → packages/components/src}/components/Check.astro +0 -0
  74. /package/{src → packages/components/src}/components/Color.astro +0 -0
  75. /package/{src → packages/components/src}/components/ColorItem.astro +0 -0
  76. /package/{src → packages/components/src}/components/ColorRow.astro +0 -0
  77. /package/{src → packages/components/src}/components/Column.astro +0 -0
  78. /package/{src → packages/components/src}/components/Columns.astro +0 -0
  79. /package/{src → packages/components/src}/components/Danger.astro +0 -0
  80. /package/{src → packages/components/src}/components/Expandable.astro +0 -0
  81. /package/{src → packages/components/src}/components/Frame.astro +0 -0
  82. /package/{src → packages/components/src}/components/GitHubRepo.astro +0 -0
  83. /package/{src → packages/components/src}/components/Hint.astro +0 -0
  84. /package/{src → packages/components/src}/components/Icon.astro +0 -0
  85. /package/{src → packages/components/src}/components/Info.astro +0 -0
  86. /package/{src → packages/components/src}/components/Note.astro +0 -0
  87. /package/{src → packages/components/src}/components/Panel.astro +0 -0
  88. /package/{src → packages/components/src}/components/ParamField.astro +0 -0
  89. /package/{src → packages/components/src}/components/Parameter.astro +0 -0
  90. /package/{src → packages/components/src}/components/Prompt.astro +0 -0
  91. /package/{src → packages/components/src}/components/RequestExample.astro +0 -0
  92. /package/{src → packages/components/src}/components/ResponseExample.astro +0 -0
  93. /package/{src → packages/components/src}/components/ResponseField.astro +0 -0
  94. /package/{src → packages/components/src}/components/Searchbar.astro +0 -0
  95. /package/{src → packages/components/src}/components/Step.astro +0 -0
  96. /package/{src → packages/components/src}/components/Steps.astro +0 -0
  97. /package/{src → packages/components/src}/components/Tab.astro +0 -0
  98. /package/{src → packages/components/src}/components/Tabs.astro +0 -0
  99. /package/{src → packages/components/src}/components/Tile.astro +0 -0
  100. /package/{src → packages/components/src}/components/Tip.astro +0 -0
  101. /package/{src → packages/components/src}/components/Tooltip.astro +0 -0
  102. /package/{src → packages/components/src}/components/Tree.astro +0 -0
  103. /package/{src → packages/components/src}/components/TreeFile.astro +0 -0
  104. /package/{src → packages/components/src}/components/TreeFolder.astro +0 -0
  105. /package/{src → packages/components/src}/components/Update.astro +0 -0
  106. /package/{src → packages/components/src}/components/Video.astro +0 -0
  107. /package/{src → packages/components/src}/components/View.astro +0 -0
  108. /package/{src → packages/components/src}/components/Visibility.astro +0 -0
  109. /package/{src → packages/components/src}/components/Warning.astro +0 -0
  110. /package/{src → packages/components/src}/components/class-names.ts +0 -0
  111. /package/{src → packages/components/src}/lib/cli-report.js +0 -0
  112. /package/{src → packages/components/src}/lib/inline-markdown.js +0 -0
  113. /package/{src → packages/components/src}/lib/plain-text.js +0 -0
@@ -32,46 +32,46 @@ import Sidebar from "../layout/components/Sidebar.astro";
32
32
  import TableOfContents from "../layout/components/TableOfContents.astro";
33
33
  import Breadcrumbs from "../layout/components/Breadcrumbs.astro";
34
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";
35
+ import Callout from "../../packages/components/src/components/Callout.astro";
36
+ import Note from "../../packages/components/src/components/Note.astro";
37
+ import Info from "../../packages/components/src/components/Info.astro";
38
+ import Tip from "../../packages/components/src/components/Tip.astro";
39
+ import Warning from "../../packages/components/src/components/Warning.astro";
40
+ import Danger from "../../packages/components/src/components/Danger.astro";
41
+ import Card from "../../packages/components/src/components/Card.astro";
42
+ import CardGroup from "../../packages/components/src/components/CardGroup.astro";
43
+ import Tabs from "../../packages/components/src/components/Tabs.astro";
44
+ import Tab from "../../packages/components/src/components/Tab.astro";
45
+ import CodeGroup from "../../packages/components/src/components/CodeGroup.astro";
46
+ import Accordion from "../../packages/components/src/components/Accordion.astro";
47
+ import AccordionGroup from "../../packages/components/src/components/AccordionGroup.astro";
48
+ import Steps from "../../packages/components/src/components/Steps.astro";
49
+ import Step from "../../packages/components/src/components/Step.astro";
50
+ import Hint from "../../packages/components/src/components/Hint.astro";
51
+ import Image from "../../packages/components/src/components/Image.astro";
52
+ import Frame from "../../packages/components/src/components/Frame.astro";
53
+ import Video from "../../packages/components/src/components/Video.astro";
54
+ import Parameter from "../../packages/components/src/components/Parameter.astro";
55
+ import Expandable from "../../packages/components/src/components/Expandable.astro";
56
+ import Searchbar from "../../packages/components/src/components/Searchbar.astro";
57
+ import Badge from "../../packages/components/src/components/Badge.astro";
58
+ import Icon from "../../packages/components/src/components/Icon.astro";
59
+ import RequestExample from "../../packages/components/src/components/RequestExample.astro";
60
+ import ResponseExample from "../../packages/components/src/components/ResponseExample.astro";
61
+ import Check from "../../packages/components/src/components/Check.astro";
62
+ import ParamField from "../../packages/components/src/components/ParamField.astro";
63
+ import ResponseField from "../../packages/components/src/components/ResponseField.astro";
64
+ import Columns from "../../packages/components/src/components/Columns.astro";
65
+ import Column from "../../packages/components/src/components/Column.astro";
66
+ import CodeBlock from "../../packages/components/src/components/CodeBlock.astro";
67
+ import Tooltip from "../../packages/components/src/components/Tooltip.astro";
68
+ import Update from "../../packages/components/src/components/Update.astro";
69
+ import Tile from "../../packages/components/src/components/Tile.astro";
70
+ import Panel from "../../packages/components/src/components/Panel.astro";
71
+ import Prompt from "../../packages/components/src/components/Prompt.astro";
72
+ import View from "../../packages/components/src/components/View.astro";
73
+ import Visibility from "../../packages/components/src/components/Visibility.astro";
74
+ import { Tree, FileTree, Color, GitHub } from "../../packages/components/src/components/compound";
75
75
  import ApiPlayground from "../components/ApiPlayground.astro";
76
76
  import ApiReferencePanel from "../components/ApiReferencePanel.astro";
77
77
  import { searchScope, sectionTrail, ALL_SCOPES } from "../lib/search-scope.js";
@@ -79,10 +79,11 @@ import { selectorPlacements } from "../lib/selector-placement.js";
79
79
  import { spaceOf } from "../lib/hidden-sections.js";
80
80
  import { navigationPageOrder } from "../lib/pages.js";
81
81
  import { folderRedirects } from "../lib/folder-redirects.js";
82
+ import { DRAFT_BANNER_HTML } from "../lib/drafts.js";
82
83
  import { oncePerBuild } from "../lib/build-memo.js";
83
84
  // 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";
85
+ // ("/guides/a/"); the base goes in where one is written (the components package's lib/site-base.ts).
86
+ import { siteHref } from "../../packages/components/src/lib/site-base";
86
87
 
87
88
  // A page is hand-written (the `pages` collection, sourced from anywhere
88
89
  // in the project - docs/ has no special status, see findAllPages() in
@@ -508,7 +509,11 @@ const selectors = landing
508
509
  // be found by), and the version/language/product it belongs to - search
509
510
  // shows the reader's own first. A hidden page belongs to no section.
510
511
  const pageSearchScope = isHidden ? { key: ALL_SCOPES, label: "" } : searchScope(activeSection.path);
511
- const pageSectionTrail = isHidden ? "" : sectionTrail(activeSection.path, breadcrumbs);
512
+ // A draft (only in `writedocs dev` and `build --drafts` - lib/drafts.js)
513
+ // says so on its search result's section line.
514
+ const pageSectionTrail = [entry.data.draft ? "Draft" : "", isHidden ? "" : sectionTrail(activeSection.path, breadcrumbs)]
515
+ .filter(Boolean)
516
+ .join(" · ");
512
517
  // A page under a hidden navigation item searches its own index, not the
513
518
  // site's (lib/hidden-sections.js, cli/run-pagefind.js).
514
519
  const pageSearchSpace = isHidden ? null : spaceOf(activeSection.path);
@@ -678,6 +683,7 @@ const components = {
678
683
  // a data-pagefind-body wrapper so a hand-built page's own text is
679
684
  // still searchable.
680
685
  <div class="wd-canvas" data-pagefind-body>
686
+ {entry.data.draft && <Fragment set:html={DRAFT_BANNER_HTML} />}
681
687
  <Content components={components} />
682
688
  {entry.data.openapi && <ApiPlayground operation={entry.data.openapi} contentDir={contentDir} />}
683
689
  {/* After the content: a result's excerpt shows the section only when
@@ -696,6 +702,11 @@ const components = {
696
702
  </div>
697
703
  ) : (
698
704
  <article class={`wd-article ${pageMode === "wide" ? "wd-article-wide" : ""}`} data-pagefind-body>
705
+ {
706
+ // A draft page - only in `writedocs dev` and `build --drafts`
707
+ // (lib/drafts.js): a strip at the top saying so.
708
+ entry.data.draft && <Fragment set:html={DRAFT_BANNER_HTML} />
709
+ }
699
710
  {breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} />}
700
711
  <div class="wd-article-header">
701
712
  {
@@ -797,6 +808,7 @@ const components = {
797
808
 
798
809
  <script>
799
810
  import { mcpServerUrl, cursorInstallLink, vscodeInstallLink } from "../lib/mcp-links.js";
811
+ import { initCodeCopyButtons, initCodeExpandButtons } from "../../packages/components/src/scripts/code-block";
800
812
  // writedocs.json's `basePath` ("" or "/docs", astro.config.mjs) - the MCP
801
813
  // server is at the site's root, under it. Written as `__WD_BASE__ ? ... : ...`
802
814
  // so a site without one gets the same code as before basePath existed.
@@ -826,31 +838,10 @@ const components = {
826
838
 
827
839
  // Copy-to-clipboard button for every fenced (```) code block - the
828
840
  // 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
- }
841
+ // (astro.config.mjs / the components package's lib/shiki-code-block.js),
842
+ // wrapping each <pre> in a .wd-code-block container; the package's
843
+ // scripts/code-block.ts wires up the click behavior client-side, same
844
+ // dataset-guarded init pattern as addHeadingAnchors above.
854
845
  initCodeCopyButtons(document);
855
846
  document.addEventListener("astro:page-load", () => initCodeCopyButtons(document));
856
847
 
@@ -940,38 +931,8 @@ const components = {
940
931
  initMcpMenu(document);
941
932
  document.addEventListener("astro:page-load", () => initMcpMenu(document));
942
933
 
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
- }
934
+ // Show more/less toggle for ```js expandable code blocks - from the
935
+ // components package too, like the copy button above.
975
936
  initCodeExpandButtons(document);
976
937
  document.addEventListener("astro:page-load", () => initCodeExpandButtons(document));
977
938
 
@@ -1356,312 +1317,6 @@ const components = {
1356
1317
  border-top: 1px solid var(--wd-border);
1357
1318
  margin: 2.5rem 0;
1358
1319
  }
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
1320
  .wd-article img {
1666
1321
  max-width: 100%;
1667
1322
  border-radius: 0.5rem;
@@ -1706,19 +1361,12 @@ const components = {
1706
1361
  .wd-article > h4 a[href^="#"] {
1707
1362
  text-decoration: none;
1708
1363
  }
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
- }
1364
+ /* .wd-heading-anchor's own look - hidden until hover or focus - is the
1365
+ components package's (styles/components.css): Callout and Accordion
1366
+ titles have one too. */
1718
1367
  .wd-article > h2:hover .wd-heading-anchor,
1719
1368
  .wd-article > h3:hover .wd-heading-anchor,
1720
- .wd-article > h4:hover .wd-heading-anchor,
1721
- .wd-heading-anchor:focus {
1369
+ .wd-article > h4:hover .wd-heading-anchor {
1722
1370
  opacity: 1;
1723
1371
  }
1724
1372
  /* RequestExample/ResponseExample.astro's own panels, and the
@@ -1,62 +0,0 @@
1
- // Re-exports every component a page's own MDX gets for free (see the
2
- // `components` map passed to `<Content components={components} />` in
3
- // src/pages/[...slug].astro) as a stable, importable barrel - so
4
- // hand-authored content that *isn't* rendered through that same call site
5
- // can still use them without reaching into the package's internals.
6
- //
7
- // The one real consumer today is snippets (see docs/dev/docs/snippets.mdx):
8
- // a page's own MDX never needs this - Callout, Card, etc. are already in
9
- // scope there with no import at all - but an MDX *snippet*, imported and
10
- // rendered as `<MySnippet />` from inside that page, is its own
11
- // independently-compiled MDX component with its own (empty, unless passed
12
- // explicitly) components map, so a `<Callout>` used inside a snippet's own
13
- // body has nothing to resolve against without an import of its own. This
14
- // module is that import: `import { Callout } from 'writedocs/components'`
15
- // (see the `"./components"` entry in package.json's `exports` field, which
16
- // is what makes that bare specifier resolve at all - Node/Vite's package
17
- // self-reference resolution, no relative path into node_modules needed).
18
- //
19
- // Deliberately the same set passed into <Content components={...}> and no
20
- // more - AppIcon, ApiPlayground, ApiReferencePanel, CopyPageMenu etc. are
21
- // internal building blocks other components/layouts use, never meant to be
22
- // dropped into a page's MDX directly, so they're left out here too.
23
- export { default as Callout } from './Callout.astro';
24
- export { default as Note } from './Note.astro';
25
- export { default as Info } from './Info.astro';
26
- export { default as Tip } from './Tip.astro';
27
- export { default as Warning } from './Warning.astro';
28
- export { default as Danger } from './Danger.astro';
29
- export { default as Card } from './Card.astro';
30
- export { default as CardGroup } from './CardGroup.astro';
31
- export { default as Tabs } from './Tabs.astro';
32
- export { default as Tab } from './Tab.astro';
33
- export { default as CodeGroup } from './CodeGroup.astro';
34
- export { default as Accordion } from './Accordion.astro';
35
- export { default as AccordionGroup } from './AccordionGroup.astro';
36
- export { default as Steps } from './Steps.astro';
37
- export { default as Step } from './Step.astro';
38
- export { default as Hint } from './Hint.astro';
39
- export { default as Image } from './Image.astro';
40
- export { default as Frame } from './Frame.astro';
41
- export { default as Video } from './Video.astro';
42
- export { default as Parameter } from './Parameter.astro';
43
- export { default as Expandable } from './Expandable.astro';
44
- export { default as Searchbar } from './Searchbar.astro';
45
- export { default as Badge } from './Badge.astro';
46
- export { default as Icon } from './Icon.astro';
47
- export { default as RequestExample } from './RequestExample.astro';
48
- export { default as ResponseExample } from './ResponseExample.astro';
49
- export { default as Check } from './Check.astro';
50
- export { default as ParamField } from './ParamField.astro';
51
- export { default as ResponseField } from './ResponseField.astro';
52
- export { default as Columns } from './Columns.astro';
53
- export { default as Column } from './Column.astro';
54
- export { default as CodeBlock } from './CodeBlock.astro';
55
- export { default as Tooltip } from './Tooltip.astro';
56
- export { default as Update } from './Update.astro';
57
- export { default as Tile } from './Tile.astro';
58
- export { default as Panel } from './Panel.astro';
59
- export { default as Prompt } from './Prompt.astro';
60
- export { default as View } from './View.astro';
61
- export { default as Visibility } from './Visibility.astro';
62
- export { Tree, FileTree, Color, GitHub } from './compound';