@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,192 +1,193 @@
1
- ---
2
- import { extraClasses } from './class-names';
3
- import AppIcon from './AppIcon.astro';
4
-
5
- // Three visual variants, chosen by which optional prop is set - never more
6
- // than one of icon/img/method actually renders at once, but they're kept
7
- // as independent props (not a single `variant` union) since `icon` is
8
- // meant to keep working exactly as before for existing content, and `href`
9
- // applies identically to all three.
10
- interface Props {
11
- title: string;
12
- icon?: string;
13
- // Renders a full-width image above the title instead of AppIcon's small
14
- // icon - takes priority over `icon` if both are somehow set (see the
15
- // template below), since a real image is the more deliberate/specific
16
- // choice of the two.
17
- img?: string;
18
- // API-reference style: a solid, colored method badge next to the title,
19
- // top-right. Same 5 known methods + fallback-gray "other" as the
20
- // sidebar's own OpenAPI badges (NavTree.astro's wd-nav-method-*) and the
21
- // Try-it playground's header (ApiPlayground.astro's wd-api-method-*) -
22
- // this is a third, independent copy of that same get/post/put/patch/
23
- // delete color set rather than a shared import, consistent with how
24
- // those two already don't share one either (different visual treatment
25
- // each - tinted pill in the sidebar, solid pill in the playground, solid
26
- // pill here too but sized for a card heading, not worth forcing into one
27
- // generic component over a handful of literal hex values).
28
- method?: string;
29
- href?: string;
30
- // Mintlify's Card props: `color` tints the icon, `horizontal` puts the
31
- // icon beside the text instead of above it, `cta` adds a call-to-action
32
- // line at the bottom, and `arrow` marks a linked card with an arrow in
33
- // its corner.
34
- color?: string;
35
- horizontal?: boolean;
36
- cta?: string;
37
- arrow?: boolean;
38
- }
39
- const { title, icon, img, method, href, color, horizontal = false, cta, arrow = false } = Astro.props as Props;
40
- const iconStyle = color ? `color: ${color}` : undefined;
41
- // An icon written as markup (an inline <svg>), moved into the `wd-icon` slot
42
- // by lib/mdx-title-anchor-ids.js.
43
- const iconHtml = Astro.slots.has('wd-icon') ? (await Astro.slots.render('wd-icon')).trim() : '';
44
- const Tag = href ? 'a' : 'div';
45
- const KNOWN_METHODS = ['get', 'post', 'put', 'patch', 'delete'];
46
- const methodLower = method?.toLowerCase();
47
- const methodClass = methodLower && KNOWN_METHODS.includes(methodLower) ? methodLower : 'other';
48
- ---
49
- <Tag class:list={['wd-card', { 'wd-card-horizontal': horizontal, 'wd-card-has-arrow': arrow && href }, extraClasses(Astro.props)]} href={href}>
50
- {img && <img src={img} alt="" class="wd-card-image" />}
51
- {!img && (iconHtml ? <span class="wd-card-icon" style={iconStyle} set:html={iconHtml} /> : <AppIcon icon={icon} class="wd-card-icon" style={iconStyle} />)}
52
- <div class="wd-card-text">
53
- <div class="wd-card-title-row">
54
- <h3 class="wd-card-title">{title}</h3>
55
- {
56
- method && (
57
- <span class:list={['wd-card-method', `wd-card-method-${methodClass}`]}>
58
- {method.toUpperCase()}
59
- </span>
60
- )
61
- }
62
- </div>
63
- <div class="wd-card-body"><slot /></div>
64
- {cta && <span class="wd-card-cta">{cta} <span aria-hidden="true">&rarr;</span></span>}
65
- </div>
66
- {arrow && href && <span class="wd-card-arrow" aria-hidden="true">&#8599;</span>}
67
- </Tag>
68
- <style>
69
- .wd-card {
70
- display: block;
71
- border: 1px solid var(--wd-border);
72
- border-radius: 0.6rem;
73
- padding: 1.1rem 1.2rem;
74
- text-decoration: none;
75
- color: inherit;
76
- transition: border-color 0.15s ease;
77
- }
78
- a.wd-card:hover {
79
- border-color: var(--wd-primary);
80
- }
81
- /* :global() is load-bearing: AppIcon.astro renders this span/svg, not
82
- Card.astro, so it never carries Card's own scope attribute - without
83
- :global() these selectors compile to something that can never match. */
84
- :global(span.wd-card-icon) {
85
- display: block;
86
- font-size: 1.3rem;
87
- }
88
- :global(svg.wd-card-icon) {
89
- display: block;
90
- width: 1.3rem;
91
- height: 1.3rem;
92
- }
93
- .wd-card-image {
94
- display: block;
95
- width: 100%;
96
- height: 9rem;
97
- object-fit: cover;
98
- border-radius: 0.4rem;
99
- background: var(--wd-surface);
100
- }
101
- /* Same 0.4rem/0.3rem the title itself used to carry directly, moved up
102
- onto this wrapper so it stays correct whether the row holds just a
103
- title (icon/img/no-icon variants) or a title + method badge side by
104
- side - a flex row's own margin does the same job a block element's
105
- margin did, without changing how any existing (no-method) card looks. */
106
- .wd-card-title-row {
107
- display: flex;
108
- align-items: center;
109
- justify-content: space-between;
110
- gap: 0.5rem;
111
- margin: 0.4rem 0 0.3rem;
112
- }
113
- .wd-card-title {
114
- margin: 0;
115
- font-size: 1rem;
116
- color: var(--wd-heading);
117
- }
118
- .wd-card-method {
119
- flex-shrink: 0;
120
- display: inline-block;
121
- padding: 0.2rem 0.55rem;
122
- border-radius: 0.3rem;
123
- font-size: 0.72rem;
124
- font-weight: 700;
125
- letter-spacing: 0.02em;
126
- color: #fff;
127
- }
128
- .wd-card-method-get {
129
- background: #16a34a;
130
- }
131
- .wd-card-method-post {
132
- background: #2563eb;
133
- }
134
- .wd-card-method-put {
135
- background: #9333ea;
136
- }
137
- .wd-card-method-patch {
138
- background: #d97706;
139
- }
140
- .wd-card-method-delete {
141
- background: #dc2626;
142
- }
143
- .wd-card-method-other {
144
- background: var(--wd-text-muted);
145
- }
146
- .wd-card-body {
147
- font-size: 0.9rem;
148
- color: var(--wd-text);
149
- margin: 0;
150
- }
151
- .wd-card-body :global(p) {
152
- margin: 0;
153
- }
154
- /* Icon in its own column beside the title/body, both vertically
155
- centered - Mintlify's compact horizontal card. */
156
- .wd-card-horizontal {
157
- display: flex;
158
- align-items: center;
159
- gap: 0.9rem;
160
- }
161
- .wd-card-horizontal .wd-card-title-row {
162
- margin-top: 0;
163
- }
164
- .wd-card-text {
165
- min-width: 0;
166
- flex: 1;
167
- }
168
- .wd-card-cta {
169
- display: inline-block;
170
- margin-top: 0.7rem;
171
- font-size: 0.85rem;
172
- font-weight: 600;
173
- color: var(--wd-primary);
174
- }
175
- /* Only a card that shows the arrow becomes a positioning context -
176
- setting it on every card changed how existing cards' text was
177
- antialiased, for no layout reason. */
178
- .wd-card-has-arrow {
179
- position: relative;
180
- }
181
- .wd-card-arrow {
182
- position: absolute;
183
- top: 0.8rem;
184
- right: 0.9rem;
185
- color: var(--wd-text-muted);
186
- font-size: 0.95rem;
187
- line-height: 1;
188
- }
189
- a.wd-card:hover .wd-card-arrow {
190
- color: var(--wd-primary);
191
- }
192
- </style>
1
+ ---
2
+ import { extraClasses } from './class-names';
3
+ import AppIcon from './AppIcon.astro';
4
+ import { siteHref } from '../lib/site-base';
5
+
6
+ // Three visual variants, chosen by which optional prop is set - never more
7
+ // than one of icon/img/method actually renders at once, but they're kept
8
+ // as independent props (not a single `variant` union) since `icon` is
9
+ // meant to keep working exactly as before for existing content, and `href`
10
+ // applies identically to all three.
11
+ interface Props {
12
+ title: string;
13
+ icon?: string;
14
+ // Renders a full-width image above the title instead of AppIcon's small
15
+ // icon - takes priority over `icon` if both are somehow set (see the
16
+ // template below), since a real image is the more deliberate/specific
17
+ // choice of the two.
18
+ img?: string;
19
+ // API-reference style: a solid, colored method badge next to the title,
20
+ // top-right. Same 5 known methods + fallback-gray "other" as the
21
+ // sidebar's own OpenAPI badges (NavTree.astro's wd-nav-method-*) and the
22
+ // Try-it playground's header (ApiPlayground.astro's wd-api-method-*) -
23
+ // this is a third, independent copy of that same get/post/put/patch/
24
+ // delete color set rather than a shared import, consistent with how
25
+ // those two already don't share one either (different visual treatment
26
+ // each - tinted pill in the sidebar, solid pill in the playground, solid
27
+ // pill here too but sized for a card heading, not worth forcing into one
28
+ // generic component over a handful of literal hex values).
29
+ method?: string;
30
+ href?: string;
31
+ // Mintlify's Card props: `color` tints the icon, `horizontal` puts the
32
+ // icon beside the text instead of above it, `cta` adds a call-to-action
33
+ // line at the bottom, and `arrow` marks a linked card with an arrow in
34
+ // its corner.
35
+ color?: string;
36
+ horizontal?: boolean;
37
+ cta?: string;
38
+ arrow?: boolean;
39
+ }
40
+ const { title, icon, img, method, href, color, horizontal = false, cta, arrow = false } = Astro.props as Props;
41
+ const iconStyle = color ? `color: ${color}` : undefined;
42
+ // An icon written as markup (an inline <svg>), moved into the `wd-icon` slot
43
+ // by lib/mdx-title-anchor-ids.js.
44
+ const iconHtml = Astro.slots.has('wd-icon') ? (await Astro.slots.render('wd-icon')).trim() : '';
45
+ const Tag = href ? 'a' : 'div';
46
+ const KNOWN_METHODS = ['get', 'post', 'put', 'patch', 'delete'];
47
+ const methodLower = method?.toLowerCase();
48
+ const methodClass = methodLower && KNOWN_METHODS.includes(methodLower) ? methodLower : 'other';
49
+ ---
50
+ <Tag class:list={['wd-card', { 'wd-card-horizontal': horizontal, 'wd-card-has-arrow': arrow && href }, extraClasses(Astro.props)]} href={siteHref(href)}>
51
+ {img && <img src={siteHref(img)} alt="" class="wd-card-image" />}
52
+ {!img && (iconHtml ? <span class="wd-card-icon" style={iconStyle} set:html={iconHtml} /> : <AppIcon icon={icon} class="wd-card-icon" style={iconStyle} />)}
53
+ <div class="wd-card-text">
54
+ <div class="wd-card-title-row">
55
+ <h3 class="wd-card-title">{title}</h3>
56
+ {
57
+ method && (
58
+ <span class:list={['wd-card-method', `wd-card-method-${methodClass}`]}>
59
+ {method.toUpperCase()}
60
+ </span>
61
+ )
62
+ }
63
+ </div>
64
+ <div class="wd-card-body"><slot /></div>
65
+ {cta && <span class="wd-card-cta">{cta} <span aria-hidden="true">&rarr;</span></span>}
66
+ </div>
67
+ {arrow && href && <span class="wd-card-arrow" aria-hidden="true">&#8599;</span>}
68
+ </Tag>
69
+ <style>
70
+ .wd-card {
71
+ display: block;
72
+ border: 1px solid var(--wd-border);
73
+ border-radius: 0.6rem;
74
+ padding: 1.1rem 1.2rem;
75
+ text-decoration: none;
76
+ color: inherit;
77
+ transition: border-color 0.15s ease;
78
+ }
79
+ a.wd-card:hover {
80
+ border-color: var(--wd-primary);
81
+ }
82
+ /* :global() is load-bearing: AppIcon.astro renders this span/svg, not
83
+ Card.astro, so it never carries Card's own scope attribute - without
84
+ :global() these selectors compile to something that can never match. */
85
+ :global(span.wd-card-icon) {
86
+ display: block;
87
+ font-size: 1.3rem;
88
+ }
89
+ :global(svg.wd-card-icon) {
90
+ display: block;
91
+ width: 1.3rem;
92
+ height: 1.3rem;
93
+ }
94
+ .wd-card-image {
95
+ display: block;
96
+ width: 100%;
97
+ height: 9rem;
98
+ object-fit: cover;
99
+ border-radius: 0.4rem;
100
+ background: var(--wd-surface);
101
+ }
102
+ /* Same 0.4rem/0.3rem the title itself used to carry directly, moved up
103
+ onto this wrapper so it stays correct whether the row holds just a
104
+ title (icon/img/no-icon variants) or a title + method badge side by
105
+ side - a flex row's own margin does the same job a block element's
106
+ margin did, without changing how any existing (no-method) card looks. */
107
+ .wd-card-title-row {
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: space-between;
111
+ gap: 0.5rem;
112
+ margin: 0.4rem 0 0.3rem;
113
+ }
114
+ .wd-card-title {
115
+ margin: 0;
116
+ font-size: 1rem;
117
+ color: var(--wd-heading);
118
+ }
119
+ .wd-card-method {
120
+ flex-shrink: 0;
121
+ display: inline-block;
122
+ padding: 0.2rem 0.55rem;
123
+ border-radius: 0.3rem;
124
+ font-size: 0.72rem;
125
+ font-weight: 700;
126
+ letter-spacing: 0.02em;
127
+ color: #fff;
128
+ }
129
+ .wd-card-method-get {
130
+ background: #16a34a;
131
+ }
132
+ .wd-card-method-post {
133
+ background: #2563eb;
134
+ }
135
+ .wd-card-method-put {
136
+ background: #9333ea;
137
+ }
138
+ .wd-card-method-patch {
139
+ background: #d97706;
140
+ }
141
+ .wd-card-method-delete {
142
+ background: #dc2626;
143
+ }
144
+ .wd-card-method-other {
145
+ background: var(--wd-text-muted);
146
+ }
147
+ .wd-card-body {
148
+ font-size: 0.9rem;
149
+ color: var(--wd-text);
150
+ margin: 0;
151
+ }
152
+ .wd-card-body :global(p) {
153
+ margin: 0;
154
+ }
155
+ /* Icon in its own column beside the title/body, both vertically
156
+ centered - Mintlify's compact horizontal card. */
157
+ .wd-card-horizontal {
158
+ display: flex;
159
+ align-items: center;
160
+ gap: 0.9rem;
161
+ }
162
+ .wd-card-horizontal .wd-card-title-row {
163
+ margin-top: 0;
164
+ }
165
+ .wd-card-text {
166
+ min-width: 0;
167
+ flex: 1;
168
+ }
169
+ .wd-card-cta {
170
+ display: inline-block;
171
+ margin-top: 0.7rem;
172
+ font-size: 0.85rem;
173
+ font-weight: 600;
174
+ color: var(--wd-primary);
175
+ }
176
+ /* Only a card that shows the arrow becomes a positioning context -
177
+ setting it on every card changed how existing cards' text was
178
+ antialiased, for no layout reason. */
179
+ .wd-card-has-arrow {
180
+ position: relative;
181
+ }
182
+ .wd-card-arrow {
183
+ position: absolute;
184
+ top: 0.8rem;
185
+ right: 0.9rem;
186
+ color: var(--wd-text-muted);
187
+ font-size: 0.95rem;
188
+ line-height: 1;
189
+ }
190
+ a.wd-card:hover .wd-card-arrow {
191
+ color: var(--wd-primary);
192
+ }
193
+ </style>