@writedocs/generator 0.10.20 → 0.11.1
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 +3 -1
- package/src/cli/astro-output.js +44 -11
- package/src/cli/base-path-layout.js +44 -0
- package/src/cli/build.js +18 -9
- package/src/cli/check-built-styles.js +41 -33
- package/src/cli/dev.js +21 -4
- 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 +245 -237
- package/writedocs.schema.json +6 -0
|
@@ -1,370 +1,374 @@
|
|
|
1
|
-
---
|
|
2
|
-
// The "Copy page" split button - on by default, showing the options
|
|
3
|
-
// writedocs.json's `contextMenu` leaves on (`options`, from
|
|
4
|
-
// contextMenuOptions() in lib/config-schema.ts). With `copy`, a primary button
|
|
5
|
-
// (always-visible "Copy page" action, copies this page's Markdown
|
|
6
|
-
// straight to the clipboard on click - see initCopyPageMenu() in
|
|
7
|
-
// [...slug].astro) plus a small caret-only button next to it that opens
|
|
8
|
-
// a dropdown for the rest (View as Markdown, Open in ChatGPT/Claude/
|
|
9
|
-
// Perplexity) - only the caret button is a .wd-dropdown-trigger, so only
|
|
10
|
-
// clicking (or hovering, per the shared CSS) *it* opens the menu, not
|
|
11
|
-
// the primary action next to it. The dropdown itself reuses the exact
|
|
12
|
-
// .wd-dropdown/.wd-dropdown-trigger/.wd-dropdown-menu/
|
|
13
|
-
// .wd-dropdown-menu-panel markup pattern BaseLayout.astro's topbar
|
|
14
|
-
// selectors already use - open/close/outside-click/Escape all come free
|
|
15
|
-
// from BaseLayout's initDropdowns(document), which queries `.wd-dropdown`
|
|
16
|
-
// anywhere in the page, not just its own template. See BaseLayout.astro's
|
|
17
|
-
// own comment on the :global() wrapping its copy of that CSS needed so
|
|
18
|
-
// the rules reach markup rendered by a different component (this one).
|
|
19
|
-
//
|
|
20
|
-
// Rendered from [...slug].astro (see its own comment on where/when),
|
|
21
|
-
// which passes in everything needed to build both same-origin links (the
|
|
22
|
-
// .md route from [...slug].md.ts) and the external "Open in X" links
|
|
23
|
-
// (which need an absolute URL - from writedocs.json's `domain` when it's
|
|
24
|
-
// set, else from the page's own address in the browser; see
|
|
25
|
-
// enabledAssistants below).
|
|
26
|
-
// Without `copy`, the options get a labeled "Page options" trigger of their
|
|
27
|
-
// own - or, when there's just one, that option is the button itself ("Open
|
|
28
|
-
// in Claude"). With only `copy`, the primary button stands alone.
|
|
29
|
-
//
|
|
30
|
-
// The last three options connect AI tools to the site's MCP server (/mcp -
|
|
31
|
-
// see docs/dev/docs/mcp.mdx): copy its address, or add it to Cursor or VS
|
|
32
|
-
// Code through their install links (lib/mcp-links.js). [...slug].astro
|
|
33
|
-
// leaves them out when writedocs.json turns `mcp` off.
|
|
34
|
-
import { Icon } from 'astro-icon/components';
|
|
35
|
-
import type { ContextMenuOption } from '../lib/config';
|
|
36
|
-
import { mcpServerUrl, cursorInstallLink, vscodeInstallLink } from '../lib/mcp-links.js';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
{ id: '
|
|
74
|
-
{ id: '
|
|
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
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
</div>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
.wd-dropdown
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
.wd-copy-page
|
|
235
|
-
display: flex;
|
|
236
|
-
align-items:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
/*
|
|
281
|
-
.wd-copy-page-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
.wd-copy-page-
|
|
309
|
-
width:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
.wd-copy-page-item
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
.wd-copy-page-item-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
.wd-copy-page-item-
|
|
367
|
-
font-size: 0.
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
|
|
1
|
+
---
|
|
2
|
+
// The "Copy page" split button - on by default, showing the options
|
|
3
|
+
// writedocs.json's `contextMenu` leaves on (`options`, from
|
|
4
|
+
// contextMenuOptions() in lib/config-schema.ts). With `copy`, a primary button
|
|
5
|
+
// (always-visible "Copy page" action, copies this page's Markdown
|
|
6
|
+
// straight to the clipboard on click - see initCopyPageMenu() in
|
|
7
|
+
// [...slug].astro) plus a small caret-only button next to it that opens
|
|
8
|
+
// a dropdown for the rest (View as Markdown, Open in ChatGPT/Claude/
|
|
9
|
+
// Perplexity) - only the caret button is a .wd-dropdown-trigger, so only
|
|
10
|
+
// clicking (or hovering, per the shared CSS) *it* opens the menu, not
|
|
11
|
+
// the primary action next to it. The dropdown itself reuses the exact
|
|
12
|
+
// .wd-dropdown/.wd-dropdown-trigger/.wd-dropdown-menu/
|
|
13
|
+
// .wd-dropdown-menu-panel markup pattern BaseLayout.astro's topbar
|
|
14
|
+
// selectors already use - open/close/outside-click/Escape all come free
|
|
15
|
+
// from BaseLayout's initDropdowns(document), which queries `.wd-dropdown`
|
|
16
|
+
// anywhere in the page, not just its own template. See BaseLayout.astro's
|
|
17
|
+
// own comment on the :global() wrapping its copy of that CSS needed so
|
|
18
|
+
// the rules reach markup rendered by a different component (this one).
|
|
19
|
+
//
|
|
20
|
+
// Rendered from [...slug].astro (see its own comment on where/when),
|
|
21
|
+
// which passes in everything needed to build both same-origin links (the
|
|
22
|
+
// .md route from [...slug].md.ts) and the external "Open in X" links
|
|
23
|
+
// (which need an absolute URL - from writedocs.json's `domain` when it's
|
|
24
|
+
// set, else from the page's own address in the browser; see
|
|
25
|
+
// enabledAssistants below).
|
|
26
|
+
// Without `copy`, the options get a labeled "Page options" trigger of their
|
|
27
|
+
// own - or, when there's just one, that option is the button itself ("Open
|
|
28
|
+
// in Claude"). With only `copy`, the primary button stands alone.
|
|
29
|
+
//
|
|
30
|
+
// The last three options connect AI tools to the site's MCP server (/mcp -
|
|
31
|
+
// see docs/dev/docs/mcp.mdx): copy its address, or add it to Cursor or VS
|
|
32
|
+
// Code through their install links (lib/mcp-links.js). [...slug].astro
|
|
33
|
+
// leaves them out when writedocs.json turns `mcp` off.
|
|
34
|
+
import { Icon } from 'astro-icon/components';
|
|
35
|
+
import type { ContextMenuOption } from '../lib/config';
|
|
36
|
+
import { mcpServerUrl, cursorInstallLink, vscodeInstallLink } from '../lib/mcp-links.js';
|
|
37
|
+
import { siteHref } from '../lib/site-base';
|
|
38
|
+
|
|
39
|
+
interface Props {
|
|
40
|
+
currentPath: string; // e.g. "/" or "/guides/foo/" - see hrefForSlug() in [...slug].astro
|
|
41
|
+
// {domain}{basePath}, or null without a `domain` (resolveSiteUrl()).
|
|
42
|
+
siteUrl: string | null;
|
|
43
|
+
siteName: string;
|
|
44
|
+
options: ContextMenuOption[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { currentPath, siteUrl, siteName, options } = Astro.props as Props;
|
|
48
|
+
|
|
49
|
+
// The [...slug].md.ts route this page is also served at - same
|
|
50
|
+
// normalizeEntryId()-driven convention that file uses to build its own
|
|
51
|
+
// getStaticPaths params ("/" -> "index.md", everything else -> its own
|
|
52
|
+
// slug with a literal ".md" appended instead of the trailing slash).
|
|
53
|
+
const mdPath = currentPath === '/' ? '/index.md' : `${currentPath.replace(/\/$/, '')}.md`;
|
|
54
|
+
const mdAbsoluteUrl = siteUrl ? `${siteUrl}${mdPath}` : null;
|
|
55
|
+
// The .md's address as the page links it - with the basePath (lib/site-base.ts).
|
|
56
|
+
const mdHref = siteHref(mdPath);
|
|
57
|
+
const mcpUrl = siteUrl ? mcpServerUrl(siteUrl) : null;
|
|
58
|
+
|
|
59
|
+
// Well-known query-string conventions for starting a new conversation
|
|
60
|
+
// pre-seeded with a prompt (not an official API for any of the three -
|
|
61
|
+
// just the same `?q=`/`/new?q=`/`/search?q=` pattern each already
|
|
62
|
+
// supports for search-engine-style deep links). Pointing the prompt at
|
|
63
|
+
// this page's own .md URL rather than pasting the page content directly
|
|
64
|
+
// into the query string keeps the link itself short and lets the
|
|
65
|
+
// assistant fetch the current content instead of a snapshot baked into
|
|
66
|
+
// a bookmarked/shared link.
|
|
67
|
+
const promptFor = (url: string) => `Read ${url} so you can answer questions about it.`;
|
|
68
|
+
|
|
69
|
+
// `base` + the URL-encoded prompt is the link; `home` is where it goes
|
|
70
|
+
// before the page script has filled the prompt in (see below).
|
|
71
|
+
const assistants = [
|
|
72
|
+
{ id: 'chatgpt' as const, label: 'ChatGPT', icon: 'simple-icons:openai', base: 'https://chatgpt.com/?q=', home: 'https://chatgpt.com/' },
|
|
73
|
+
{ id: 'claude' as const, label: 'Claude', icon: 'simple-icons:claude', base: 'https://claude.ai/new?q=', home: 'https://claude.ai/new' },
|
|
74
|
+
{ id: 'perplexity' as const, label: 'Perplexity', icon: 'simple-icons:perplexity', base: 'https://www.perplexity.ai/search?q=', home: 'https://www.perplexity.ai/' },
|
|
75
|
+
];
|
|
76
|
+
const editors = [
|
|
77
|
+
{ id: 'cursor' as const, label: 'Cursor', icon: 'simple-icons:cursor', link: cursorInstallLink, home: 'https://docs.cursor.com/context/mcp' },
|
|
78
|
+
{ id: 'vscode' as const, label: 'VS Code', icon: 'simple-icons:visualstudiocode', link: vscodeInstallLink, home: 'https://code.visualstudio.com/docs/copilot/chat/mcp-servers' },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
// Every link needs an absolute URL - the page's .md for an assistant, the
|
|
82
|
+
// MCP server for an editor. With a `domain` it's known at build time and the
|
|
83
|
+
// link is complete in the HTML. Without one, the page script ([...slug].astro)
|
|
84
|
+
// completes it from the address the page is actually served from, using the
|
|
85
|
+
// data-* attributes below; until then the link goes to the tool's own page.
|
|
86
|
+
type Item = {
|
|
87
|
+
id: ContextMenuOption;
|
|
88
|
+
title: string;
|
|
89
|
+
desc: string;
|
|
90
|
+
icon: string;
|
|
91
|
+
group: 'page' | 'mcp';
|
|
92
|
+
href?: string;
|
|
93
|
+
newTab?: boolean;
|
|
94
|
+
attrs?: Record<string, string | undefined>;
|
|
95
|
+
};
|
|
96
|
+
const items: Item[] = [];
|
|
97
|
+
if (options.includes('view')) {
|
|
98
|
+
items.push({ id: 'view', title: 'View as Markdown', desc: 'View this page as plain text', icon: 'lucide:external-link', group: 'page', href: mdHref, newTab: true });
|
|
99
|
+
}
|
|
100
|
+
for (const a of assistants.filter((a) => options.includes(a.id))) {
|
|
101
|
+
items.push({
|
|
102
|
+
id: a.id,
|
|
103
|
+
title: `Open in ${a.label}`,
|
|
104
|
+
desc: 'Ask questions about this page',
|
|
105
|
+
icon: a.icon,
|
|
106
|
+
group: 'page',
|
|
107
|
+
href: mdAbsoluteUrl ? a.base + encodeURIComponent(promptFor(mdAbsoluteUrl)) : a.home,
|
|
108
|
+
newTab: true,
|
|
109
|
+
attrs: mdAbsoluteUrl ? undefined : { 'data-ask-base': a.base, 'data-md-path': mdHref },
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (options.includes('mcp')) {
|
|
113
|
+
items.push({ id: 'mcp', title: 'Copy MCP server URL', desc: 'Connect AI tools to these docs', icon: 'simple-icons:modelcontextprotocol', group: 'mcp', attrs: { 'data-copy-mcp': mcpUrl ?? '' } });
|
|
114
|
+
}
|
|
115
|
+
for (const e of editors.filter((e) => options.includes(e.id))) {
|
|
116
|
+
items.push({
|
|
117
|
+
id: e.id,
|
|
118
|
+
title: `Connect to ${e.label}`,
|
|
119
|
+
desc: `Use these docs in ${e.label}`,
|
|
120
|
+
icon: e.icon,
|
|
121
|
+
group: 'mcp',
|
|
122
|
+
// An editor's own link scheme (cursor://, vscode:) - opens the app, not a tab.
|
|
123
|
+
href: mcpUrl ? e.link(siteName, mcpUrl) : e.home,
|
|
124
|
+
attrs: mcpUrl ? undefined : { 'data-mcp-install': e.id, 'data-mcp-name': siteName },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const showCopy = options.includes('copy');
|
|
129
|
+
// One option and no "Copy page": that option is the button.
|
|
130
|
+
const single = !showCopy && items.length === 1 ? items[0] : null;
|
|
131
|
+
const hasDropdown = items.length > 0 && !single;
|
|
132
|
+
---
|
|
133
|
+
{(showCopy || items.length > 0) && (
|
|
134
|
+
<div class="wd-copy-page-split" data-pagefind-ignore="all" data-markdown-ignore>
|
|
135
|
+
{showCopy && (
|
|
136
|
+
<button type="button" class:list={['wd-copy-page-primary', { 'wd-copy-page-alone': !hasDropdown }]} data-copy-page data-md-path={mdHref} aria-label="Copy page as Markdown">
|
|
137
|
+
<Icon name="lucide:copy" class="wd-copy-page-icon" />
|
|
138
|
+
<span class="wd-copy-page-primary-label">Copy page</span>
|
|
139
|
+
</button>
|
|
140
|
+
)}
|
|
141
|
+
{single && (single.href ? (
|
|
142
|
+
<a class="wd-copy-page-primary wd-copy-page-alone" href={single.href} target={single.newTab ? '_blank' : undefined} rel={single.newTab ? 'noopener' : undefined} {...single.attrs}>
|
|
143
|
+
<Icon name={single.icon} class="wd-copy-page-icon" />
|
|
144
|
+
<span class="wd-copy-page-primary-label">{single.title}</span>
|
|
145
|
+
</a>
|
|
146
|
+
) : (
|
|
147
|
+
<button type="button" class="wd-copy-page-primary wd-copy-page-alone" {...single.attrs}>
|
|
148
|
+
<Icon name={single.icon} class="wd-copy-page-icon" />
|
|
149
|
+
<span class="wd-copy-page-primary-label">{single.title}</span>
|
|
150
|
+
</button>
|
|
151
|
+
))}
|
|
152
|
+
{hasDropdown && (
|
|
153
|
+
<div class="wd-dropdown wd-copy-page">
|
|
154
|
+
<button type="button" class:list={['wd-dropdown-trigger', 'wd-copy-page-caret-trigger', { 'wd-copy-page-labeled-trigger': !showCopy }]} aria-expanded="false" aria-label={showCopy ? 'More copy options' : 'Page options'}>
|
|
155
|
+
{!showCopy && (
|
|
156
|
+
<>
|
|
157
|
+
<Icon name="lucide:sparkles" class="wd-copy-page-icon" />
|
|
158
|
+
<span class="wd-copy-page-primary-label">Page options</span>
|
|
159
|
+
</>
|
|
160
|
+
)}
|
|
161
|
+
<svg class="wd-dropdown-caret" width="10" height="10" viewBox="0 0 10 10" aria-hidden="true">
|
|
162
|
+
<path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round" />
|
|
163
|
+
</svg>
|
|
164
|
+
</button>
|
|
165
|
+
<div class="wd-dropdown-menu wd-copy-page-menu">
|
|
166
|
+
<div class="wd-dropdown-menu-panel wd-copy-page-menu-panel">
|
|
167
|
+
{items.map((item, i) => (
|
|
168
|
+
<>
|
|
169
|
+
{i > 0 && item.group !== items[i - 1].group && <hr class="wd-copy-page-divider" />}
|
|
170
|
+
{item.href ? (
|
|
171
|
+
<a class="wd-copy-page-item" href={item.href} target={item.newTab ? '_blank' : undefined} rel={item.newTab ? 'noopener' : undefined} {...item.attrs}>
|
|
172
|
+
<Icon name={item.icon} class="wd-copy-page-icon" />
|
|
173
|
+
<span class="wd-copy-page-item-text">
|
|
174
|
+
<span class="wd-copy-page-item-title">{item.title}</span>
|
|
175
|
+
<span class="wd-copy-page-item-desc">{item.desc}</span>
|
|
176
|
+
</span>
|
|
177
|
+
</a>
|
|
178
|
+
) : (
|
|
179
|
+
<button type="button" class="wd-copy-page-item" {...item.attrs}>
|
|
180
|
+
<Icon name={item.icon} class="wd-copy-page-icon" />
|
|
181
|
+
<span class="wd-copy-page-item-text">
|
|
182
|
+
<span class="wd-copy-page-item-title">{item.title}</span>
|
|
183
|
+
<span class="wd-copy-page-item-desc">{item.desc}</span>
|
|
184
|
+
</span>
|
|
185
|
+
</button>
|
|
186
|
+
)}
|
|
187
|
+
</>
|
|
188
|
+
))}
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
</div>
|
|
194
|
+
)}
|
|
195
|
+
|
|
196
|
+
<style>
|
|
197
|
+
/* The split button: a primary "Copy page" action (always visible,
|
|
198
|
+
copies on click - see initCopyPageMenu() in [...slug].astro) and a
|
|
199
|
+
small caret-only button next to it that opens the rest (View as
|
|
200
|
+
Markdown, Open in X). Each button gets its own half of the shared
|
|
201
|
+
border-radius (left corners on the primary button, right corners on
|
|
202
|
+
the caret button) rather than `overflow: hidden` on the wrapper -
|
|
203
|
+
overflow: hidden was tried first and clips more than intended: the
|
|
204
|
+
dropdown menu itself is an absolutely-positioned descendant of
|
|
205
|
+
.wd-dropdown, which lives inside this wrapper, so clipping the
|
|
206
|
+
wrapper's overflow silently clipped the open menu away too (the
|
|
207
|
+
caret still visibly rotated on hover/open, since that's a transform
|
|
208
|
+
on the caret itself, not the menu - only the menu's own visibility
|
|
209
|
+
was affected, which is what made this look like "nothing happens"
|
|
210
|
+
rather than an obvious rendering glitch). */
|
|
211
|
+
.wd-copy-page-split {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: stretch;
|
|
214
|
+
border: 1px solid var(--wd-border);
|
|
215
|
+
border-radius: 0.4rem;
|
|
216
|
+
flex-shrink: 0;
|
|
217
|
+
/* Right-aligned on its own line too (a long title on a phone sends it
|
|
218
|
+
below the title) - its menu opens leftwards, and stays on screen. */
|
|
219
|
+
margin-left: auto;
|
|
220
|
+
}
|
|
221
|
+
/* .wd-copy-page is this instance's own class on the .wd-dropdown div
|
|
222
|
+
wrapping the caret button + menu (see BaseLayout.astro's shared
|
|
223
|
+
.wd-dropdown rule for `position: relative`, which still applies
|
|
224
|
+
alongside this). .wd-copy-page-split's `align-items: stretch` above
|
|
225
|
+
stretches this div's own height to match the primary button next to
|
|
226
|
+
it, but that alone doesn't stretch the *caret button inside it* -
|
|
227
|
+
.wd-dropdown is a plain block div, not a flex container, so its
|
|
228
|
+
child sizes itself independently and just sits at the top of the
|
|
229
|
+
now-taller div, which is what made the arrow look vertically
|
|
230
|
+
off-center against the primary button. Making this div a flex
|
|
231
|
+
container too (with its own stretch) propagates the height down to
|
|
232
|
+
the button, which centers the svg within it via the shared
|
|
233
|
+
.wd-dropdown-trigger rule's own align-items: center. */
|
|
234
|
+
.wd-copy-page {
|
|
235
|
+
display: flex;
|
|
236
|
+
align-items: stretch;
|
|
237
|
+
}
|
|
238
|
+
.wd-copy-page-primary {
|
|
239
|
+
display: flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
gap: 0.35rem;
|
|
242
|
+
padding: 0.35rem 0.65rem;
|
|
243
|
+
border: none;
|
|
244
|
+
border-radius: 0.35rem 0 0 0.35rem;
|
|
245
|
+
background: none;
|
|
246
|
+
cursor: pointer;
|
|
247
|
+
color: var(--wd-text-muted);
|
|
248
|
+
font-size: 0.85rem;
|
|
249
|
+
font-weight: 500;
|
|
250
|
+
font-family: inherit;
|
|
251
|
+
}
|
|
252
|
+
.wd-copy-page-primary:hover {
|
|
253
|
+
color: var(--wd-text);
|
|
254
|
+
background: var(--wd-surface);
|
|
255
|
+
}
|
|
256
|
+
/* Toggled by initCopyPageMenu() for ~1.5s after a successful copy -
|
|
257
|
+
the label itself swaps to "Copied!" via JS (not CSS content, so a
|
|
258
|
+
screen reader announces it), this just tints icon+text green to
|
|
259
|
+
match. */
|
|
260
|
+
.wd-copy-page-primary.wd-copy-page-copied {
|
|
261
|
+
color: #16a34a;
|
|
262
|
+
}
|
|
263
|
+
/* Overrides the shared .wd-dropdown-trigger base rule (BaseLayout.astro)
|
|
264
|
+
down to an icon-only square button - no padding/border of its own
|
|
265
|
+
beyond the divider line, and only the right corners rounded (to
|
|
266
|
+
match .wd-copy-page-split's own outer radius on that side - see the
|
|
267
|
+
comment above on why the wrapper itself no longer clips to its
|
|
268
|
+
radius via overflow: hidden). */
|
|
269
|
+
.wd-copy-page-caret-trigger {
|
|
270
|
+
padding: 0.35rem 0.5rem;
|
|
271
|
+
border: none;
|
|
272
|
+
border-left: 1px solid var(--wd-border);
|
|
273
|
+
border-radius: 0 0.35rem 0.35rem 0;
|
|
274
|
+
}
|
|
275
|
+
/* Only one of the two halves: it gets all four corners (and, for the
|
|
276
|
+
trigger, no divider line and a label like the primary button's). */
|
|
277
|
+
.wd-copy-page-primary.wd-copy-page-alone {
|
|
278
|
+
border-radius: 0.35rem;
|
|
279
|
+
}
|
|
280
|
+
/* The single-option button can be a link ("Open in Claude"). */
|
|
281
|
+
a.wd-copy-page-primary {
|
|
282
|
+
text-decoration: none;
|
|
283
|
+
}
|
|
284
|
+
/* Between the page's options and the MCP server's. */
|
|
285
|
+
.wd-copy-page-divider {
|
|
286
|
+
margin: 0.3rem 0.4rem;
|
|
287
|
+
border: none;
|
|
288
|
+
border-top: 1px solid var(--wd-border);
|
|
289
|
+
}
|
|
290
|
+
.wd-copy-page-caret-trigger.wd-copy-page-labeled-trigger {
|
|
291
|
+
gap: 0.35rem;
|
|
292
|
+
padding: 0.35rem 0.65rem;
|
|
293
|
+
border-left: none;
|
|
294
|
+
border-radius: 0.35rem;
|
|
295
|
+
color: var(--wd-text-muted);
|
|
296
|
+
font-size: 0.85rem;
|
|
297
|
+
font-weight: 500;
|
|
298
|
+
}
|
|
299
|
+
.wd-copy-page-menu {
|
|
300
|
+
left: auto;
|
|
301
|
+
right: 0;
|
|
302
|
+
}
|
|
303
|
+
/* overflow: hidden here (in addition to .wd-copy-page-item below no
|
|
304
|
+
longer overflowing its own box) is defensive belt-and-suspenders -
|
|
305
|
+
keeps any future item's hover background from ever visibly poking
|
|
306
|
+
past the panel's own rounded corners, the exact bug .wd-copy-page-item
|
|
307
|
+
used to have. */
|
|
308
|
+
.wd-copy-page-menu-panel {
|
|
309
|
+
min-width: 260px;
|
|
310
|
+
overflow: hidden;
|
|
311
|
+
}
|
|
312
|
+
.wd-copy-page-icon {
|
|
313
|
+
width: 1em;
|
|
314
|
+
height: 1em;
|
|
315
|
+
flex-shrink: 0;
|
|
316
|
+
}
|
|
317
|
+
/* .wd-dropdown-menu a (BaseLayout.astro) is single-line only
|
|
318
|
+
(align-items: center on one row of text) - these items need a
|
|
319
|
+
title + description subtitle, so .wd-copy-page-item re-implements
|
|
320
|
+
that layout instead (icon top-aligned next to a two-line text
|
|
321
|
+
stack) rather than trying to make the shared single-line rule cover
|
|
322
|
+
both shapes.
|
|
323
|
+
No explicit `width` here - deliberately: this codebase doesn't set
|
|
324
|
+
a global `box-sizing: border-box` reset (see the comment on
|
|
325
|
+
Tailwind's preflight in src/styles/global.css), so a block-level
|
|
326
|
+
element's default `width: auto` already correctly fills its
|
|
327
|
+
container *net of* its own padding, while an explicit `width: 100%`
|
|
328
|
+
would add that padding on top instead, overflowing past the
|
|
329
|
+
container's edge - exactly what an earlier version of this rule did
|
|
330
|
+
(visible as the hover background bleeding out past the panel's
|
|
331
|
+
rounded corner on hover). Leave width unset rather than reaching for
|
|
332
|
+
`box-sizing: border-box` here alone, which would just be one rule
|
|
333
|
+
quietly relying on a codebase-wide convention it doesn't establish. */
|
|
334
|
+
.wd-copy-page-item {
|
|
335
|
+
display: flex;
|
|
336
|
+
align-items: flex-start;
|
|
337
|
+
gap: 0.6rem;
|
|
338
|
+
padding: 0.5rem 0.6rem;
|
|
339
|
+
border: none;
|
|
340
|
+
border-radius: 0.35rem;
|
|
341
|
+
background: none;
|
|
342
|
+
text-decoration: none;
|
|
343
|
+
color: var(--wd-text);
|
|
344
|
+
font-family: inherit;
|
|
345
|
+
text-align: left;
|
|
346
|
+
cursor: pointer;
|
|
347
|
+
}
|
|
348
|
+
/* A button option ("Copy MCP server URL") fills the row like the links
|
|
349
|
+
do - a button sizes to its content otherwise. */
|
|
350
|
+
button.wd-copy-page-item {
|
|
351
|
+
width: 100%;
|
|
352
|
+
box-sizing: border-box;
|
|
353
|
+
}
|
|
354
|
+
.wd-copy-page-item:hover {
|
|
355
|
+
background: var(--wd-surface);
|
|
356
|
+
}
|
|
357
|
+
.wd-copy-page-item .wd-copy-page-icon {
|
|
358
|
+
margin-top: 0.15rem;
|
|
359
|
+
color: var(--wd-text-muted);
|
|
360
|
+
}
|
|
361
|
+
.wd-copy-page-item-text {
|
|
362
|
+
display: flex;
|
|
363
|
+
flex-direction: column;
|
|
364
|
+
gap: 0.1rem;
|
|
365
|
+
}
|
|
366
|
+
.wd-copy-page-item-title {
|
|
367
|
+
font-size: 0.86rem;
|
|
368
|
+
font-weight: 500;
|
|
369
|
+
}
|
|
370
|
+
.wd-copy-page-item-desc {
|
|
371
|
+
font-size: 0.76rem;
|
|
372
|
+
color: var(--wd-text-muted);
|
|
373
|
+
}
|
|
374
|
+
</style>
|