@writedocs/generator 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +28 -28
  2. package/astro.config.mjs +645 -645
  3. package/bin/writedocs.js +359 -356
  4. package/package.json +99 -99
  5. package/src/cli/base-path-layout.js +44 -44
  6. package/src/cli/build-auth.js +135 -135
  7. package/src/cli/build.js +223 -203
  8. package/src/cli/check-built-styles.js +41 -41
  9. package/src/cli/convert.js +124 -124
  10. package/src/cli/dev.js +269 -268
  11. package/src/cli/exit-when-flushed.js +42 -42
  12. package/src/cli/generate-api-pages.js +509 -507
  13. package/src/cli/og-image-worker.js +20 -20
  14. package/src/cli/og-images.js +70 -70
  15. package/src/cli/page-list-watch.js +71 -69
  16. package/src/cli/run-astro.js +97 -97
  17. package/src/cli/run-pagefind.js +154 -154
  18. package/src/cli/write-mcp-files.js +103 -103
  19. package/src/cli/write-redirects-file.js +158 -158
  20. package/src/components/ApiReferencePanel.astro +1792 -1792
  21. package/src/components/AppIcon.astro +51 -51
  22. package/src/components/Card.astro +193 -193
  23. package/src/components/CodeGroup.astro +63 -39
  24. package/src/components/CopyPageMenu.astro +374 -374
  25. package/src/components/Hint.astro +188 -188
  26. package/src/components/Icon.astro +72 -72
  27. package/src/components/Image.astro +165 -165
  28. package/src/components/Tile.astro +67 -67
  29. package/src/components/Video.astro +137 -137
  30. package/src/content.config.ts +219 -203
  31. package/src/layout/BaseLayout.astro +908 -908
  32. package/src/layout/components/AnalyticsScripts.astro +49 -49
  33. package/src/layout/components/Breadcrumbs.astro +98 -98
  34. package/src/layout/components/ConsentBanner.astro +119 -119
  35. package/src/layout/components/MobileMenu.astro +225 -225
  36. package/src/layout/components/NavTree.astro +422 -408
  37. package/src/layout/components/Sidebar.astro +232 -232
  38. package/src/layout/components/SiteFooter.astro +87 -87
  39. package/src/layout/components/TopBar.astro +386 -386
  40. package/src/layout/styles/base.css +332 -326
  41. package/src/layout/styles/mobile-menu.css +285 -285
  42. package/src/lib/agent-markdown.js +164 -164
  43. package/src/lib/asset-dimensions.js +89 -89
  44. package/src/lib/base-path.js +90 -90
  45. package/src/lib/cli-report.js +22 -22
  46. package/src/lib/code-line-numbers.js +13 -0
  47. package/src/lib/config-schema.js +12 -1
  48. package/src/lib/config-schema.ts +2523 -2509
  49. package/src/lib/config.ts +1331 -1316
  50. package/src/lib/consent.js +108 -108
  51. package/src/lib/content-check.js +4 -1
  52. package/src/lib/content-store-reload-integration.js +101 -101
  53. package/src/lib/drafts.js +186 -0
  54. package/src/lib/icon-data-dev.js +53 -53
  55. package/src/lib/image-size.js +152 -152
  56. package/src/lib/json-schema-descriptions.js +228 -228
  57. package/src/lib/link-check.js +553 -544
  58. package/src/lib/llms-index.ts +90 -90
  59. package/src/lib/mcp-dev-integration.js +65 -65
  60. package/src/lib/mcp-index.ts +102 -102
  61. package/src/lib/mintlify-convert.js +605 -605
  62. package/src/lib/moved-api-pages.js +49 -49
  63. package/src/lib/og-cards.js +33 -33
  64. package/src/lib/og-image.js +235 -235
  65. package/src/lib/openapi-dev-status.js +80 -80
  66. package/src/lib/openapi-reload-integration.js +193 -193
  67. package/src/lib/pages.js +346 -312
  68. package/src/lib/project-files-integration.js +116 -116
  69. package/src/lib/project-files.js +137 -137
  70. package/src/lib/rehype-base-path.js +62 -62
  71. package/src/lib/rehype-image-loading.js +71 -71
  72. package/src/lib/robots-txt.js +21 -21
  73. package/src/lib/search-scope.js +44 -44
  74. package/src/lib/selector-placement.js +50 -50
  75. package/src/lib/seo-tags.js +157 -155
  76. package/src/lib/shiki-code-block.js +7 -1
  77. package/src/lib/site-base.ts +27 -27
  78. package/src/lib/styles-asset-integration.js +291 -291
  79. package/src/lib/wdignore-cases.json +195 -195
  80. package/src/lib/wdignore.js +177 -177
  81. package/src/pages/404.astro +63 -63
  82. package/src/pages/[...slug].astro +1773 -1608
  83. package/src/pages/[...slug].md.ts +93 -93
  84. package/src/pages/llms-full.txt.ts +88 -88
  85. package/src/pages/og/[...slug].png.ts +63 -63
  86. package/src/scripts/mobile-menu.ts +80 -80
  87. package/src/scripts/search.ts +245 -245
  88. package/src/scripts/sidebar-scroll.ts +61 -61
  89. package/src/styles/global.css +40 -40
@@ -1,188 +1,188 @@
1
- ---
2
- import { extraClasses } from './class-names';
3
- import { siteHref } from '../lib/site-base';
4
- // Inline, text-level component - unlike every other built-in here
5
- // (Callout, Card, Accordion, ...), which are all block-level and get
6
- // their own line, a Hint sits mid-sentence: `word <Hint tip="...">this
7
- // bit</Hint> continues`. That's why this renders a <span>, not a <div>,
8
- // and why its own trigger area is its slotted text plus, by default, a
9
- // small info icon after it - a dotted underline and that icon are the
10
- // whole cue, no padding box drawing attention to itself the way a Callout
11
- // does. `icon={false}` leaves just the underlined text.
12
- //
13
- // tip is a plain string prop (not a slot) deliberately - the tooltip
14
- // bubble itself needs to be one line of plain text CSS can center/
15
- // position predictably; a second <slot> would let an author put
16
- // arbitrary markup (another Hint, a link, a whole paragraph) in there,
17
- // which the hover-bubble layout below was never built to hold.
18
- //
19
- // `headline`, `cta` and `href` exist for Mintlify's <Tooltip> (see
20
- // Tooltip.astro): an optional bold line above the tip, and an optional
21
- // link below it. They're still plain strings, not slots - same reasoning
22
- // as above. A tooltip with a link has to stay open while the pointer moves
23
- // from the trigger onto the bubble, so the bubble takes pointer events
24
- // once shown, and a transparent ::before bridges the gap between them.
25
- interface Props {
26
- tip: string;
27
- headline?: string;
28
- cta?: string;
29
- href?: string;
30
- /** The small info icon after the text. On unless set to false. */
31
- icon?: boolean;
32
- }
33
- const { tip, headline, cta, href, icon = true } = Astro.props as Props;
34
- const hasLink = Boolean(cta && href);
35
- ---
36
-
37
- <span class:list={["wd-hint", { "wd-hint-rich": Boolean(headline) || hasLink }, extraClasses(Astro.props)]} tabindex="0">
38
- <span class="wd-hint-trigger"><slot /></span>{icon && (
39
- <svg class="wd-hint-icon" viewBox="0 0 24 24" aria-hidden="true">
40
- <circle cx="12" cy="12" r="9.5" />
41
- <path d="M12 16.5v-5M12 8h.01" />
42
- </svg>
43
- )}
44
- <span class="wd-hint-tooltip" role="tooltip">
45
- {headline && <span class="wd-hint-headline">{headline}</span>}
46
- <span class="wd-hint-tip">{tip}</span>
47
- {hasLink && <a class="wd-hint-cta" href={siteHref(href)}>{cta}</a>}
48
- </span>
49
- </span>
50
- <style>
51
- .wd-hint {
52
- position: relative;
53
- /* display: inline, not inline-block - this needs to be able to wrap
54
- across a line break exactly like the plain text around it would
55
- (it's often a whole sentence, not one short word), which
56
- inline-block would prevent by forcing the whole span to stay on
57
- one line or break as a single rigid box. */
58
- display: inline;
59
- /* tabindex above + :focus-visible below make this reachable and
60
- revealable by keyboard, not just a mouse hover - the underline
61
- and cursor: help both double as the visual cue that there's a
62
- hint here at all, since nothing about plain underlined text
63
- otherwise signals "hover me" the way an icon or button would. */
64
- cursor: help;
65
- }
66
- /* A dotted underline under the text, drawn by the font's own underline
67
- rather than a border, so it follows the text across a line break and
68
- sits clear of descenders. */
69
- .wd-hint-trigger {
70
- text-decoration-line: underline;
71
- text-decoration-style: dotted;
72
- text-decoration-thickness: 2px;
73
- text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
74
- text-underline-offset: 0.22em;
75
- }
76
- .wd-hint:hover .wd-hint-trigger,
77
- .wd-hint:focus-visible .wd-hint-trigger {
78
- text-decoration-color: currentColor;
79
- }
80
- /* Smaller than the text, a little clear of it, in the muted color. */
81
- .wd-hint-icon {
82
- display: inline-block;
83
- width: 0.72em;
84
- height: 0.72em;
85
- margin-left: 0.22em;
86
- vertical-align: -0.04em;
87
- fill: none;
88
- stroke: currentColor;
89
- stroke-width: 2.2;
90
- stroke-linecap: round;
91
- stroke-linejoin: round;
92
- color: var(--wd-text-muted);
93
- transition: color 0.15s ease;
94
- }
95
- .wd-hint:hover .wd-hint-icon,
96
- .wd-hint:focus-visible .wd-hint-icon {
97
- color: var(--wd-text);
98
- }
99
- .wd-hint-tooltip {
100
- position: absolute;
101
- bottom: calc(100% + 0.55rem);
102
- left: 50%;
103
- transform: translateX(-50%) translateY(4px);
104
- /* Fixed dark-on-light regardless of [data-theme] - deliberately not
105
- var(--wd-text)/var(--wd-background) (which flip a Hint's own
106
- tooltip to light-on-dark in dark mode) since the bubble needs to
107
- read as "a label floating above the page", the same fixed
108
- look in both themes, not as page content that itself follows the
109
- theme - the same reasoning Card.astro's method badges already
110
- settled on for their own always-colored, never-theme-flipping
111
- backgrounds. */
112
- background: #18181b;
113
- color: #fff;
114
- padding: 0.45rem 0.75rem;
115
- border-radius: 0.4rem;
116
- font-size: 0.75rem;
117
- font-weight: 700;
118
- line-height: 1.3;
119
- /* No white-space: nowrap - a long tip (a UUID example, a full
120
- sentence) needs to actually wrap onto a second line within
121
- max-width; nowrap combined with max-width caps the *box* but
122
- leaves overflow: visible's default behavior letting the text
123
- itself spill out past the painted background/border-radius
124
- instead of wrapping inside it - exactly the "text sticking out
125
- past the dark bubble" bug a real screenshot caught. Wrapping
126
- normally keeps the background sized to whatever it's actually
127
- covering, at the cost of a short tip's box no longer perfectly
128
- hugging one line's width (an intentional trade - a tip that's
129
- readable matters more than one that's minimally-sized). */
130
- max-width: 16rem;
131
- width: max-content;
132
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
133
- opacity: 0;
134
- visibility: hidden;
135
- pointer-events: none;
136
- transition:
137
- opacity 0.15s ease,
138
- transform 0.15s ease,
139
- visibility 0.15s;
140
- z-index: 30;
141
- }
142
- .wd-hint-tooltip::after {
143
- content: "";
144
- position: absolute;
145
- top: 100%;
146
- left: 50%;
147
- transform: translateX(-50%);
148
- border: 5px solid transparent;
149
- border-top-color: #18181b;
150
- }
151
- .wd-hint:hover .wd-hint-tooltip,
152
- .wd-hint:focus-visible .wd-hint-tooltip,
153
- .wd-hint:focus-within .wd-hint-tooltip {
154
- opacity: 1;
155
- visibility: visible;
156
- transform: translateX(-50%) translateY(0);
157
- }
158
- /* Only a tooltip with a headline or link is interactive - a plain one
159
- keeps pointer-events: none so it never blocks the text under it. */
160
- .wd-hint-rich:hover .wd-hint-tooltip,
161
- .wd-hint-rich:focus-within .wd-hint-tooltip {
162
- pointer-events: auto;
163
- }
164
- .wd-hint-rich .wd-hint-tooltip::before {
165
- content: "";
166
- position: absolute;
167
- top: 100%;
168
- left: 0;
169
- right: 0;
170
- height: 0.6rem;
171
- }
172
- .wd-hint-tip,
173
- .wd-hint-headline,
174
- .wd-hint-cta {
175
- display: block;
176
- }
177
- .wd-hint-rich .wd-hint-tip {
178
- font-weight: 400;
179
- }
180
- .wd-hint-headline {
181
- margin-bottom: 0.2rem;
182
- }
183
- .wd-hint-cta {
184
- margin-top: 0.35rem;
185
- color: #93c5fd;
186
- text-decoration: underline;
187
- }
188
- </style>
1
+ ---
2
+ import { extraClasses } from './class-names';
3
+ import { siteHref } from '../lib/site-base';
4
+ // Inline, text-level component - unlike every other built-in here
5
+ // (Callout, Card, Accordion, ...), which are all block-level and get
6
+ // their own line, a Hint sits mid-sentence: `word <Hint tip="...">this
7
+ // bit</Hint> continues`. That's why this renders a <span>, not a <div>,
8
+ // and why its own trigger area is its slotted text plus, by default, a
9
+ // small info icon after it - a dotted underline and that icon are the
10
+ // whole cue, no padding box drawing attention to itself the way a Callout
11
+ // does. `icon={false}` leaves just the underlined text.
12
+ //
13
+ // tip is a plain string prop (not a slot) deliberately - the tooltip
14
+ // bubble itself needs to be one line of plain text CSS can center/
15
+ // position predictably; a second <slot> would let an author put
16
+ // arbitrary markup (another Hint, a link, a whole paragraph) in there,
17
+ // which the hover-bubble layout below was never built to hold.
18
+ //
19
+ // `headline`, `cta` and `href` exist for Mintlify's <Tooltip> (see
20
+ // Tooltip.astro): an optional bold line above the tip, and an optional
21
+ // link below it. They're still plain strings, not slots - same reasoning
22
+ // as above. A tooltip with a link has to stay open while the pointer moves
23
+ // from the trigger onto the bubble, so the bubble takes pointer events
24
+ // once shown, and a transparent ::before bridges the gap between them.
25
+ interface Props {
26
+ tip: string;
27
+ headline?: string;
28
+ cta?: string;
29
+ href?: string;
30
+ /** The small info icon after the text. On unless set to false. */
31
+ icon?: boolean;
32
+ }
33
+ const { tip, headline, cta, href, icon = true } = Astro.props as Props;
34
+ const hasLink = Boolean(cta && href);
35
+ ---
36
+
37
+ <span class:list={["wd-hint", { "wd-hint-rich": Boolean(headline) || hasLink }, extraClasses(Astro.props)]} tabindex="0">
38
+ <span class="wd-hint-trigger"><slot /></span>{icon && (
39
+ <svg class="wd-hint-icon" viewBox="0 0 24 24" aria-hidden="true">
40
+ <circle cx="12" cy="12" r="9.5" />
41
+ <path d="M12 16.5v-5M12 8h.01" />
42
+ </svg>
43
+ )}
44
+ <span class="wd-hint-tooltip" role="tooltip">
45
+ {headline && <span class="wd-hint-headline">{headline}</span>}
46
+ <span class="wd-hint-tip">{tip}</span>
47
+ {hasLink && <a class="wd-hint-cta" href={siteHref(href)}>{cta}</a>}
48
+ </span>
49
+ </span>
50
+ <style>
51
+ .wd-hint {
52
+ position: relative;
53
+ /* display: inline, not inline-block - this needs to be able to wrap
54
+ across a line break exactly like the plain text around it would
55
+ (it's often a whole sentence, not one short word), which
56
+ inline-block would prevent by forcing the whole span to stay on
57
+ one line or break as a single rigid box. */
58
+ display: inline;
59
+ /* tabindex above + :focus-visible below make this reachable and
60
+ revealable by keyboard, not just a mouse hover - the underline
61
+ and cursor: help both double as the visual cue that there's a
62
+ hint here at all, since nothing about plain underlined text
63
+ otherwise signals "hover me" the way an icon or button would. */
64
+ cursor: help;
65
+ }
66
+ /* A dotted underline under the text, drawn by the font's own underline
67
+ rather than a border, so it follows the text across a line break and
68
+ sits clear of descenders. */
69
+ .wd-hint-trigger {
70
+ text-decoration-line: underline;
71
+ text-decoration-style: dotted;
72
+ text-decoration-thickness: 2px;
73
+ text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
74
+ text-underline-offset: 0.22em;
75
+ }
76
+ .wd-hint:hover .wd-hint-trigger,
77
+ .wd-hint:focus-visible .wd-hint-trigger {
78
+ text-decoration-color: currentColor;
79
+ }
80
+ /* Smaller than the text, a little clear of it, in the muted color. */
81
+ .wd-hint-icon {
82
+ display: inline-block;
83
+ width: 0.72em;
84
+ height: 0.72em;
85
+ margin-left: 0.22em;
86
+ vertical-align: -0.04em;
87
+ fill: none;
88
+ stroke: currentColor;
89
+ stroke-width: 2.2;
90
+ stroke-linecap: round;
91
+ stroke-linejoin: round;
92
+ color: var(--wd-text-muted);
93
+ transition: color 0.15s ease;
94
+ }
95
+ .wd-hint:hover .wd-hint-icon,
96
+ .wd-hint:focus-visible .wd-hint-icon {
97
+ color: var(--wd-text);
98
+ }
99
+ .wd-hint-tooltip {
100
+ position: absolute;
101
+ bottom: calc(100% + 0.55rem);
102
+ left: 50%;
103
+ transform: translateX(-50%) translateY(4px);
104
+ /* Fixed dark-on-light regardless of [data-theme] - deliberately not
105
+ var(--wd-text)/var(--wd-background) (which flip a Hint's own
106
+ tooltip to light-on-dark in dark mode) since the bubble needs to
107
+ read as "a label floating above the page", the same fixed
108
+ look in both themes, not as page content that itself follows the
109
+ theme - the same reasoning Card.astro's method badges already
110
+ settled on for their own always-colored, never-theme-flipping
111
+ backgrounds. */
112
+ background: #18181b;
113
+ color: #fff;
114
+ padding: 0.45rem 0.75rem;
115
+ border-radius: 0.4rem;
116
+ font-size: 0.75rem;
117
+ font-weight: 700;
118
+ line-height: 1.3;
119
+ /* No white-space: nowrap - a long tip (a UUID example, a full
120
+ sentence) needs to actually wrap onto a second line within
121
+ max-width; nowrap combined with max-width caps the *box* but
122
+ leaves overflow: visible's default behavior letting the text
123
+ itself spill out past the painted background/border-radius
124
+ instead of wrapping inside it - exactly the "text sticking out
125
+ past the dark bubble" bug a real screenshot caught. Wrapping
126
+ normally keeps the background sized to whatever it's actually
127
+ covering, at the cost of a short tip's box no longer perfectly
128
+ hugging one line's width (an intentional trade - a tip that's
129
+ readable matters more than one that's minimally-sized). */
130
+ max-width: 16rem;
131
+ width: max-content;
132
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
133
+ opacity: 0;
134
+ visibility: hidden;
135
+ pointer-events: none;
136
+ transition:
137
+ opacity 0.15s ease,
138
+ transform 0.15s ease,
139
+ visibility 0.15s;
140
+ z-index: 30;
141
+ }
142
+ .wd-hint-tooltip::after {
143
+ content: "";
144
+ position: absolute;
145
+ top: 100%;
146
+ left: 50%;
147
+ transform: translateX(-50%);
148
+ border: 5px solid transparent;
149
+ border-top-color: #18181b;
150
+ }
151
+ .wd-hint:hover .wd-hint-tooltip,
152
+ .wd-hint:focus-visible .wd-hint-tooltip,
153
+ .wd-hint:focus-within .wd-hint-tooltip {
154
+ opacity: 1;
155
+ visibility: visible;
156
+ transform: translateX(-50%) translateY(0);
157
+ }
158
+ /* Only a tooltip with a headline or link is interactive - a plain one
159
+ keeps pointer-events: none so it never blocks the text under it. */
160
+ .wd-hint-rich:hover .wd-hint-tooltip,
161
+ .wd-hint-rich:focus-within .wd-hint-tooltip {
162
+ pointer-events: auto;
163
+ }
164
+ .wd-hint-rich .wd-hint-tooltip::before {
165
+ content: "";
166
+ position: absolute;
167
+ top: 100%;
168
+ left: 0;
169
+ right: 0;
170
+ height: 0.6rem;
171
+ }
172
+ .wd-hint-tip,
173
+ .wd-hint-headline,
174
+ .wd-hint-cta {
175
+ display: block;
176
+ }
177
+ .wd-hint-rich .wd-hint-tip {
178
+ font-weight: 400;
179
+ }
180
+ .wd-hint-headline {
181
+ margin-bottom: 0.2rem;
182
+ }
183
+ .wd-hint-cta {
184
+ margin-top: 0.35rem;
185
+ color: #93c5fd;
186
+ text-decoration: underline;
187
+ }
188
+ </style>
@@ -1,72 +1,72 @@
1
- ---
2
- import { extraClasses } from './class-names';
3
- // Renders either a real icon (via `icon`) or a custom image (via
4
- // `src`) inline with surrounding text - modeled on Mintlify's own Icon
5
- // (https://www.mintlify.com/docs/components/icons), which documents
6
- // exactly this "one of `icon` or `src`" split. `icon` reuses
7
- // AppIcon.astro - the same Lucide/Iconify/literal-text resolution
8
- // every other icon prop on this site already goes through (Card,
9
- // Badge, writedocs.json's own tab/dropdown/product icons) - so this
10
- // component's `icon` prop behaves identically to theirs, just laid out
11
- // for inline text flow instead of block/flex placement.
12
- //
13
- // The `src` branch is a second, independent code path (a plain <img>,
14
- // not AppIcon) since it isn't resolving an icon set at all - it's
15
- // dropping in an arbitrary image (a project-local file or an external
16
- // URL) and just needs to sit inline at a controlled height, the exact
17
- // behavior of the InlineImage React component this was modeled on
18
- // (display: inline, a `height` prop controlling size, no margin).
19
- import AppIcon from './AppIcon.astro';
20
- import { siteHref } from '../lib/site-base';
21
-
22
- interface Props {
23
- icon?: string;
24
- src?: string;
25
- alt?: string;
26
- // Only meaningful for the `icon` branch - a pixel size (Mintlify's
27
- // own `size` prop is a number, not a CSS length) and a CSS color,
28
- // applied as an inline style since these are arbitrary per-instance
29
- // values, not a fixed set of classes.
30
- size?: number;
31
- color?: string;
32
- // Only meaningful for the `src` branch - a CSS length string (not a
33
- // bare number, unlike `size` above), matching the InlineImage
34
- // reference component's own `height` prop and its "1.6em" default.
35
- height?: string;
36
- }
37
- const { icon, src, alt = '', size, color, height = '1.6em' } = Astro.props as Props;
38
-
39
- const iconStyle =
40
- [size ? `width:${size}px` : null, size ? `height:${size}px` : null, color ? `color:${color}` : null]
41
- .filter(Boolean)
42
- .join(';') || undefined;
43
- ---
44
-
45
- {
46
- src ? (
47
- <img src={siteHref(src)} alt={alt} class:list={["wd-icon-image", extraClasses(Astro.props)]} style={`height:${height}`} />
48
- ) : icon ? (
49
- <AppIcon icon={icon} class={["wd-icon-inline", ...extraClasses(Astro.props)].join(" ")} style={iconStyle} />
50
- ) : null
51
- }
52
- <style>
53
- .wd-icon-image {
54
- display: inline;
55
- vertical-align: middle;
56
- height: 1.6em;
57
- margin: 0;
58
- }
59
- /* :global() is load-bearing, same reason as every other AppIcon
60
- consumer's identical comment (Card.astro, Badge.astro): AppIcon
61
- renders this span/svg, not Icon.astro, so it never carries this
62
- component's own scope attribute. 1em default (overridden inline
63
- via the `size` prop's style attribute when set) keeps an
64
- unsized icon proportional to its surrounding text, the same way a
65
- real glyph would be. */
66
- :global(.wd-icon-inline) {
67
- display: inline;
68
- vertical-align: middle;
69
- width: 1em;
70
- height: 1em;
71
- }
72
- </style>
1
+ ---
2
+ import { extraClasses } from './class-names';
3
+ // Renders either a real icon (via `icon`) or a custom image (via
4
+ // `src`) inline with surrounding text - modeled on Mintlify's own Icon
5
+ // (https://www.mintlify.com/docs/components/icons), which documents
6
+ // exactly this "one of `icon` or `src`" split. `icon` reuses
7
+ // AppIcon.astro - the same Lucide/Iconify/literal-text resolution
8
+ // every other icon prop on this site already goes through (Card,
9
+ // Badge, writedocs.json's own tab/dropdown/product icons) - so this
10
+ // component's `icon` prop behaves identically to theirs, just laid out
11
+ // for inline text flow instead of block/flex placement.
12
+ //
13
+ // The `src` branch is a second, independent code path (a plain <img>,
14
+ // not AppIcon) since it isn't resolving an icon set at all - it's
15
+ // dropping in an arbitrary image (a project-local file or an external
16
+ // URL) and just needs to sit inline at a controlled height, the exact
17
+ // behavior of the InlineImage React component this was modeled on
18
+ // (display: inline, a `height` prop controlling size, no margin).
19
+ import AppIcon from './AppIcon.astro';
20
+ import { siteHref } from '../lib/site-base';
21
+
22
+ interface Props {
23
+ icon?: string;
24
+ src?: string;
25
+ alt?: string;
26
+ // Only meaningful for the `icon` branch - a pixel size (Mintlify's
27
+ // own `size` prop is a number, not a CSS length) and a CSS color,
28
+ // applied as an inline style since these are arbitrary per-instance
29
+ // values, not a fixed set of classes.
30
+ size?: number;
31
+ color?: string;
32
+ // Only meaningful for the `src` branch - a CSS length string (not a
33
+ // bare number, unlike `size` above), matching the InlineImage
34
+ // reference component's own `height` prop and its "1.6em" default.
35
+ height?: string;
36
+ }
37
+ const { icon, src, alt = '', size, color, height = '1.6em' } = Astro.props as Props;
38
+
39
+ const iconStyle =
40
+ [size ? `width:${size}px` : null, size ? `height:${size}px` : null, color ? `color:${color}` : null]
41
+ .filter(Boolean)
42
+ .join(';') || undefined;
43
+ ---
44
+
45
+ {
46
+ src ? (
47
+ <img src={siteHref(src)} alt={alt} class:list={["wd-icon-image", extraClasses(Astro.props)]} style={`height:${height}`} />
48
+ ) : icon ? (
49
+ <AppIcon icon={icon} class={["wd-icon-inline", ...extraClasses(Astro.props)].join(" ")} style={iconStyle} />
50
+ ) : null
51
+ }
52
+ <style>
53
+ .wd-icon-image {
54
+ display: inline;
55
+ vertical-align: middle;
56
+ height: 1.6em;
57
+ margin: 0;
58
+ }
59
+ /* :global() is load-bearing, same reason as every other AppIcon
60
+ consumer's identical comment (Card.astro, Badge.astro): AppIcon
61
+ renders this span/svg, not Icon.astro, so it never carries this
62
+ component's own scope attribute. 1em default (overridden inline
63
+ via the `size` prop's style attribute when set) keeps an
64
+ unsized icon proportional to its surrounding text, the same way a
65
+ real glyph would be. */
66
+ :global(.wd-icon-inline) {
67
+ display: inline;
68
+ vertical-align: middle;
69
+ width: 1em;
70
+ height: 1em;
71
+ }
72
+ </style>