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