@writedocs/generator 0.10.20 → 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.
- package/astro.config.mjs +32 -8
- package/package.json +1 -1
- package/src/cli/base-path-layout.js +44 -0
- package/src/cli/build.js +177 -168
- package/src/cli/check-built-styles.js +41 -33
- package/src/cli/dev.js +261 -244
- package/src/cli/run-pagefind.js +154 -148
- package/src/cli/write-mcp-files.js +103 -96
- package/src/cli/write-redirects-file.js +25 -8
- package/src/components/AppIcon.astro +51 -50
- package/src/components/Card.astro +193 -192
- package/src/components/CopyPageMenu.astro +374 -370
- package/src/components/Hint.astro +188 -187
- package/src/components/Icon.astro +72 -71
- package/src/components/Image.astro +3 -2
- package/src/components/Tile.astro +67 -66
- package/src/components/Video.astro +137 -136
- package/src/layout/BaseLayout.astro +21 -12
- package/src/layout/components/AnalyticsScripts.astro +6 -2
- package/src/layout/components/Breadcrumbs.astro +98 -97
- package/src/layout/components/ConsentBanner.astro +119 -118
- package/src/layout/components/MobileMenu.astro +229 -228
- package/src/layout/components/NavTree.astro +393 -392
- package/src/layout/components/Sidebar.astro +232 -231
- package/src/layout/components/SiteFooter.astro +87 -86
- package/src/layout/components/TopBar.astro +386 -385
- package/src/lib/agent-markdown.js +164 -162
- package/src/lib/asset-dimensions.js +89 -89
- package/src/lib/base-path.js +90 -0
- package/src/lib/config-schema.js +10 -0
- package/src/lib/config-schema.ts +17 -0
- package/src/lib/config.ts +1314 -1289
- package/src/lib/consent.js +108 -102
- package/src/lib/json-schema-descriptions.js +1 -0
- package/src/lib/link-check.js +7 -2
- package/src/lib/llms-index.ts +90 -88
- package/src/lib/mcp-dev-integration.js +65 -60
- package/src/lib/mcp-index.ts +102 -101
- package/src/lib/project-files-integration.js +2 -2
- package/src/lib/rehype-base-path.js +62 -0
- package/src/lib/robots-txt.js +21 -16
- package/src/lib/seo-tags.js +155 -140
- package/src/lib/site-base.ts +27 -0
- package/src/lib/styles-asset-integration.js +23 -10
- package/src/lib/wdignore-cases.json +195 -195
- package/src/lib/wdignore.js +177 -177
- package/src/pages/404.astro +63 -62
- package/src/pages/[...slug].astro +1604 -1597
- package/src/pages/[...slug].md.ts +93 -93
- package/src/pages/llms-full.txt.ts +88 -86
- package/src/scripts/search.ts +241 -237
- package/writedocs.schema.json +6 -0
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
---
|
|
2
|
-
// Renders any writedocs.json `icon` string, whichever of the two forms it
|
|
3
|
-
// takes (see resolveIcon() in lib/config.ts): an Iconify icon id (looked
|
|
4
|
-
// up against whatever @iconify-json/* collections are installed - see
|
|
5
|
-
// astro.config.mjs) rendered as a real <svg>, or literal text/emoji
|
|
6
|
-
// rendered as-is. Centralizes the icon/text branch so BaseLayout.astro
|
|
7
|
-
// and Card.astro (the two places writedocs.json icon strings get rendered)
|
|
8
|
-
// don't each need their own copy of the resolveIcon() call + branch.
|
|
9
|
-
import { Icon } from 'astro-icon/components';
|
|
10
|
-
import { resolveIcon, iconExists } from '../lib/config';
|
|
11
|
-
import { report } from '../lib/cli-report.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// span
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
1
|
+
---
|
|
2
|
+
// Renders any writedocs.json `icon` string, whichever of the two forms it
|
|
3
|
+
// takes (see resolveIcon() in lib/config.ts): an Iconify icon id (looked
|
|
4
|
+
// up against whatever @iconify-json/* collections are installed - see
|
|
5
|
+
// astro.config.mjs) rendered as a real <svg>, or literal text/emoji
|
|
6
|
+
// rendered as-is. Centralizes the icon/text branch so BaseLayout.astro
|
|
7
|
+
// and Card.astro (the two places writedocs.json icon strings get rendered)
|
|
8
|
+
// don't each need their own copy of the resolveIcon() call + branch.
|
|
9
|
+
import { Icon } from 'astro-icon/components';
|
|
10
|
+
import { resolveIcon, iconExists } from '../lib/config';
|
|
11
|
+
import { report } from '../lib/cli-report.js';
|
|
12
|
+
import { siteHref } from '../lib/site-base';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
icon?: string;
|
|
16
|
+
class?: string;
|
|
17
|
+
// Optional inline style passthrough - Icon.astro is the one real
|
|
18
|
+
// consumer, needing this to apply its own per-instance `size`/`color`
|
|
19
|
+
// props (arbitrary values, not a fixed set of classes like every
|
|
20
|
+
// other AppIcon call site uses). Left off Props' required list and
|
|
21
|
+
// undefined by default so every existing caller (BaseLayout, Card,
|
|
22
|
+
// Badge) is unaffected.
|
|
23
|
+
style?: string;
|
|
24
|
+
}
|
|
25
|
+
const { icon, class: className = 'wd-icon', style } = Astro.props as Props;
|
|
26
|
+
// An icon name no installed collection has renders nothing, with a warning
|
|
27
|
+
// (once per name - a sidebar icon renders on every page), instead of
|
|
28
|
+
// failing the whole build the way astro-icon does on a missing name.
|
|
29
|
+
// `writedocs validate` lists the same names ahead of time.
|
|
30
|
+
let resolved = icon ? resolveIcon(icon) : null;
|
|
31
|
+
if (icon && resolved?.kind === 'iconify' && !iconExists(icon)) {
|
|
32
|
+
const warned: Set<string> = ((globalThis as any).__wdWarnedIcons ??= new Set());
|
|
33
|
+
if (!warned.has(icon)) {
|
|
34
|
+
warned.add(icon);
|
|
35
|
+
report('warn', `Unknown icon "${icon}" - no installed icon set has it, so it's left out.`);
|
|
36
|
+
}
|
|
37
|
+
resolved = null;
|
|
38
|
+
}
|
|
39
|
+
---
|
|
40
|
+
{resolved && (
|
|
41
|
+
resolved.kind === 'iconify' ? (
|
|
42
|
+
<Icon name={resolved.name} class={className} style={style} />
|
|
43
|
+
) : resolved.kind === 'image' ? (
|
|
44
|
+
// Wrapped in the same <span> text icons use, so each caller's own
|
|
45
|
+
// span.<class> rule (font-size, spacing) sizes it; the image fills
|
|
46
|
+
// 1em of that (img.wd-icon-img in layout/styles/base.css).
|
|
47
|
+
<span class={className} style={style}><img src={siteHref(resolved.src)} alt="" class="wd-icon-img" /></span>
|
|
48
|
+
) : (
|
|
49
|
+
<span class={className} style={style}>{resolved.value}</span>
|
|
50
|
+
)
|
|
51
|
+
)}
|
|
@@ -1,192 +1,193 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { extraClasses } from './class-names';
|
|
3
|
-
import AppIcon from './AppIcon.astro';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
border
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
font-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
font-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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">→</span></span>}
|
|
66
|
+
</div>
|
|
67
|
+
{arrow && href && <span class="wd-card-arrow" aria-hidden="true">↗</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>
|