@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.
Files changed (52) hide show
  1. package/astro.config.mjs +32 -8
  2. package/package.json +1 -1
  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/run-pagefind.js +154 -148
  8. package/src/cli/write-mcp-files.js +103 -96
  9. package/src/cli/write-redirects-file.js +25 -8
  10. package/src/components/AppIcon.astro +51 -50
  11. package/src/components/Card.astro +193 -192
  12. package/src/components/CopyPageMenu.astro +374 -370
  13. package/src/components/Hint.astro +188 -187
  14. package/src/components/Icon.astro +72 -71
  15. package/src/components/Image.astro +3 -2
  16. package/src/components/Tile.astro +67 -66
  17. package/src/components/Video.astro +137 -136
  18. package/src/layout/BaseLayout.astro +21 -12
  19. package/src/layout/components/AnalyticsScripts.astro +6 -2
  20. package/src/layout/components/Breadcrumbs.astro +98 -97
  21. package/src/layout/components/ConsentBanner.astro +119 -118
  22. package/src/layout/components/MobileMenu.astro +229 -228
  23. package/src/layout/components/NavTree.astro +393 -392
  24. package/src/layout/components/Sidebar.astro +232 -231
  25. package/src/layout/components/SiteFooter.astro +87 -86
  26. package/src/layout/components/TopBar.astro +386 -385
  27. package/src/lib/agent-markdown.js +164 -162
  28. package/src/lib/asset-dimensions.js +89 -89
  29. package/src/lib/base-path.js +90 -0
  30. package/src/lib/config-schema.js +10 -0
  31. package/src/lib/config-schema.ts +17 -0
  32. package/src/lib/config.ts +1314 -1289
  33. package/src/lib/consent.js +108 -102
  34. package/src/lib/json-schema-descriptions.js +1 -0
  35. package/src/lib/link-check.js +7 -2
  36. package/src/lib/llms-index.ts +90 -88
  37. package/src/lib/mcp-dev-integration.js +65 -60
  38. package/src/lib/mcp-index.ts +102 -101
  39. package/src/lib/project-files-integration.js +2 -2
  40. package/src/lib/rehype-base-path.js +62 -0
  41. package/src/lib/robots-txt.js +21 -16
  42. package/src/lib/seo-tags.js +155 -140
  43. package/src/lib/site-base.ts +27 -0
  44. package/src/lib/styles-asset-integration.js +23 -10
  45. package/src/lib/wdignore-cases.json +195 -195
  46. package/src/lib/wdignore.js +177 -177
  47. package/src/pages/404.astro +63 -62
  48. package/src/pages/[...slug].astro +1604 -1597
  49. package/src/pages/[...slug].md.ts +93 -93
  50. package/src/pages/llms-full.txt.ts +88 -86
  51. package/src/scripts/search.ts +241 -237
  52. package/writedocs.schema.json +6 -0
@@ -1,237 +1,241 @@
1
- // SearchModal.astro's own trigger button (rendered inside TopBar.astro) +
2
- // overlay/modal. Owns opening/closing the modal, the ⌘K/Ctrl K shortcut,
3
- // lazy-loading Pagefind on first open, and rendering results.
4
-
5
- // The current page's modal, for the ⌘K/Ctrl K shortcut. ClientRouter swaps
6
- // in a new modal on every navigation and initSearch() runs again for it; the
7
- // shortcut is one document listener, attached once, that always acts on
8
- // this. (Attached per page, it piled up one listener per visited page, each
9
- // still driving that page's detached modal - on a page without a modal of
10
- // its own, Ctrl K then locked the page's scrolling.)
11
- let active: { toggle(): void; closeIfOpen(): void } | null = null;
12
- let shortcutBound = false;
13
-
14
- export function initSearch(root: ParentNode) {
15
- // No trigger button on a `blank` page (no topbar) - the modal and its
16
- // shortcut still work there, as BaseLayout.astro intends.
17
- const trigger = root.querySelector<HTMLButtonElement>('[data-search-trigger]');
18
- const overlay = root.querySelector<HTMLElement>('#wd-search-overlay');
19
- const input = root.querySelector<HTMLInputElement>('#wd-search-input');
20
- const resultsEl = root.querySelector<HTMLElement>('#wd-search-results');
21
- if (!overlay || !input || !resultsEl) {
22
- active = null;
23
- return;
24
- }
25
- if (overlay.dataset.wdInit) return;
26
- overlay.dataset.wdInit = 'true';
27
-
28
- // Most keyboards outside macOS/iOS don't have a command key - "Ctrl K"
29
- // reads more naturally there than the ⌘ glyph.
30
- const kbd = trigger?.querySelector('.wd-search-kbd');
31
- if (kbd && !/Mac|iPhone|iPad/.test(navigator.userAgent)) {
32
- kbd.textContent = 'Ctrl K';
33
- }
34
-
35
- // Loaded lazily on first open rather than on every page load - most
36
- // visits never open search, and the module + its wasm binary are pure
37
- // overhead until someone actually wants to search. Pagefind only writes
38
- // this file as a postbuild step, after Astro's own build (and therefore
39
- // Vite's bundling) has already finished - see run-pagefind.js - so it
40
- // never exists at `writedocs dev` time, and doesn't exist yet even
41
- // during a production build's own Vite transform pass.
42
- //
43
- // `/* @vite-ignore */` alone doesn't stop Vite from trying to resolve it
44
- // anyway: that comment only suppresses static analysis for a
45
- // *non-literal* dynamic import specifier - a literal string like
46
- // '/pagefind/pagefind.js' still gets resolved at transform time
47
- // regardless of the comment, which crashes `writedocs dev` outright once
48
- // this file exists in the template. Routing the literal through a
49
- // variable first makes the specifier opaque to static analysis,
50
- // deferring resolution to the browser at runtime - where the .catch()
51
- // below handles "not built yet" gracefully instead.
52
- let pagefind: any = null;
53
- let loadPromise: Promise<any> | null = null;
54
- function ensurePagefind() {
55
- if (!loadPromise) {
56
- // A page under a hidden navigation item searches its own space's index
57
- // (cli/run-pagefind.js, lib/hidden-sections.js); every other page, the site's.
58
- const space = document.querySelector<HTMLElement>('[data-wd-search-scope]')?.dataset.wdSearchSpace;
59
- const pagefindUrl = space ? `/pagefind-spaces/${encodeURIComponent(space)}/pagefind.js` : '/pagefind/pagefind.js';
60
- loadPromise = import(/* @vite-ignore */ pagefindUrl)
61
- .then((mod: any) => {
62
- pagefind = mod;
63
- return mod.init();
64
- })
65
- .then(() => pagefind)
66
- .catch(() => {
67
- resultsEl.innerHTML =
68
- '<div class="wd-search-empty">Search isn\'t available in this preview - run a full build to index it.</div>';
69
- return null;
70
- });
71
- }
72
- return loadPromise;
73
- }
74
-
75
- let currentResults: HTMLElement[] = [];
76
- let activeIndex = -1;
77
-
78
- // Down on the last result (or Up on the first) stays there - Enter always
79
- // has a result to open.
80
- function setActive(index: number) {
81
- currentResults.forEach((el) => el.classList.remove('wd-search-result-active'));
82
- activeIndex = currentResults.length ? Math.min(Math.max(index, 0), currentResults.length - 1) : -1;
83
- if (activeIndex >= 0) {
84
- currentResults[activeIndex].classList.add('wd-search-result-active');
85
- currentResults[activeIndex].scrollIntoView({ block: 'nearest' });
86
- }
87
- }
88
-
89
- // Search looks in the version, language and product of the page the reader
90
- // is on (plus pages outside any of them), with a switch to search
91
- // everything. [...slug].astro marks each page's scope for Pagefind and
92
- // for this - see lib/search-scope.js.
93
- let everything = false;
94
- const pageScope = () => {
95
- const el = document.querySelector<HTMLElement>('[data-wd-search-scope]');
96
- const key = el?.dataset.wdSearchScope ?? 'all';
97
- return key === 'all' ? null : { key, label: el?.dataset.wdSearchScopeLabel || key };
98
- };
99
- function scopeNote(scope: { label: string } | null, found: boolean) {
100
- if (!scope) return null;
101
- const note = document.createElement('div');
102
- note.className = 'wd-search-scope';
103
- const text = document.createElement('span');
104
- const button = document.createElement('button');
105
- button.type = 'button';
106
- button.className = 'wd-search-scope-toggle';
107
- if (everything) {
108
- text.textContent = 'Showing results from the whole site.';
109
- button.textContent = `Only ${scope.label}`;
110
- } else {
111
- text.textContent = found ? `Showing results in ${scope.label}.` : `No results in ${scope.label}.`;
112
- button.textContent = 'Search everything';
113
- }
114
- button.addEventListener('click', (e) => {
115
- e.stopPropagation();
116
- everything = !everything;
117
- input.focus();
118
- runSearch(input.value);
119
- });
120
- note.append(text, ' ', button);
121
- return note;
122
- }
123
-
124
- async function runSearch(term: string) {
125
- if (!term.trim()) {
126
- resultsEl.innerHTML = '<div class="wd-search-hint">Start typing to search...</div>';
127
- currentResults = [];
128
- activeIndex = -1;
129
- return;
130
- }
131
- const pf = await ensurePagefind();
132
- if (!pf) return;
133
- // debouncedSearch resolves to null when a newer keystroke has already
134
- // superseded this call - pagefind's own debounce, on top of (not
135
- // instead of) the plain `input` listener below, so a fast typist never
136
- // races two searches rendering out of order.
137
- const scope = pageScope();
138
- const options = scope && !everything ? { filters: { any: [{ scope: scope.key }, { scope: 'all' }] } } : {};
139
- const search = await pf.debouncedSearch(term, options, 150);
140
- if (search === null) return;
141
- if (search.results.length === 0) {
142
- resultsEl.innerHTML = '<div class="wd-search-empty">No results.</div>';
143
- const note = scopeNote(scope, false);
144
- if (note) resultsEl.replaceChildren(note);
145
- currentResults = [];
146
- activeIndex = -1;
147
- return;
148
- }
149
- const entries = await Promise.all(search.results.slice(0, 12).map((r: any) => r.data()));
150
- resultsEl.innerHTML = '';
151
- for (const data of entries) {
152
- const a = document.createElement('a');
153
- a.className = 'wd-search-result';
154
- a.href = data.url;
155
- const title = document.createElement('div');
156
- title.className = 'wd-search-result-title';
157
- title.textContent = data.meta?.title ?? data.url;
158
- // Where the page sits: "API Reference › Webhooks".
159
- const section = data.meta?.section ? document.createElement('div') : null;
160
- if (section) {
161
- section.className = 'wd-search-result-section';
162
- section.textContent = data.meta.section;
163
- }
164
- const excerpt = document.createElement('div');
165
- excerpt.className = 'wd-search-result-excerpt';
166
- // innerHTML (not textContent) is deliberate: pagefind returns this
167
- // pre-sanitized with <mark> wrapping the matched terms, which is the
168
- // whole point - a plain-text excerpt couldn't highlight anything.
169
- // The section is indexed as the page's last words, so a short page's
170
- // excerpt ends with it - shown once, on its own line, unless it's what
171
- // matched (then the excerpt keeps it, highlighted).
172
- const trailing = data.meta?.section ? ` ${data.meta.section}.` : null;
173
- excerpt.innerHTML = trailing && data.excerpt.endsWith(trailing) ? data.excerpt.slice(0, -trailing.length) : data.excerpt;
174
- a.append(title, ...(section ? [section] : []), excerpt);
175
- resultsEl.appendChild(a);
176
- }
177
- const note = scopeNote(scope, true);
178
- if (note) resultsEl.appendChild(note);
179
- currentResults = Array.from(resultsEl.querySelectorAll('.wd-search-result'));
180
- setActive(0);
181
- }
182
-
183
- function open() {
184
- overlay.hidden = false;
185
- document.body.style.overflow = 'hidden';
186
- input.value = '';
187
- everything = false;
188
- resultsEl.innerHTML = '<div class="wd-search-hint">Start typing to search...</div>';
189
- currentResults = [];
190
- activeIndex = -1;
191
- ensurePagefind();
192
- input.focus();
193
- }
194
-
195
- function close() {
196
- overlay.hidden = true;
197
- document.body.style.overflow = '';
198
- trigger?.focus();
199
- }
200
-
201
- trigger?.addEventListener('click', open);
202
- overlay.addEventListener('click', (e) => {
203
- if (e.target === overlay) close();
204
- });
205
- input.addEventListener('input', () => runSearch(input.value));
206
- input.addEventListener('keydown', (e) => {
207
- if (e.key === 'ArrowDown') {
208
- e.preventDefault();
209
- setActive(activeIndex + 1);
210
- } else if (e.key === 'ArrowUp') {
211
- e.preventDefault();
212
- setActive(activeIndex - 1);
213
- } else if (e.key === 'Enter' && activeIndex >= 0) {
214
- currentResults[activeIndex]?.click();
215
- } else if (e.key === 'Escape') {
216
- close();
217
- }
218
- });
219
- active = {
220
- toggle: () => (overlay.hidden ? open() : close()),
221
- closeIfOpen: () => {
222
- if (!overlay.hidden) close();
223
- },
224
- };
225
- if (!shortcutBound) {
226
- shortcutBound = true;
227
- document.addEventListener('keydown', (e) => {
228
- if (!active) return;
229
- if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) {
230
- e.preventDefault();
231
- active.toggle();
232
- } else if (e.key === 'Escape') {
233
- active.closeIfOpen();
234
- }
235
- });
236
- }
237
- }
1
+ // SearchModal.astro's own trigger button (rendered inside TopBar.astro) +
2
+ // overlay/modal. Owns opening/closing the modal, the ⌘K/Ctrl K shortcut,
3
+ // lazy-loading Pagefind on first open, and rendering results.
4
+
5
+ // The current page's modal, for the ⌘K/Ctrl K shortcut. ClientRouter swaps
6
+ // in a new modal on every navigation and initSearch() runs again for it; the
7
+ // shortcut is one document listener, attached once, that always acts on
8
+ // this. (Attached per page, it piled up one listener per visited page, each
9
+ // still driving that page's detached modal - on a page without a modal of
10
+ // its own, Ctrl K then locked the page's scrolling.)
11
+ declare const __WD_BASE__: string;
12
+
13
+ let active: { toggle(): void; closeIfOpen(): void } | null = null;
14
+ let shortcutBound = false;
15
+
16
+ export function initSearch(root: ParentNode) {
17
+ // No trigger button on a `blank` page (no topbar) - the modal and its
18
+ // shortcut still work there, as BaseLayout.astro intends.
19
+ const trigger = root.querySelector<HTMLButtonElement>('[data-search-trigger]');
20
+ const overlay = root.querySelector<HTMLElement>('#wd-search-overlay');
21
+ const input = root.querySelector<HTMLInputElement>('#wd-search-input');
22
+ const resultsEl = root.querySelector<HTMLElement>('#wd-search-results');
23
+ if (!overlay || !input || !resultsEl) {
24
+ active = null;
25
+ return;
26
+ }
27
+ if (overlay.dataset.wdInit) return;
28
+ overlay.dataset.wdInit = 'true';
29
+
30
+ // Most keyboards outside macOS/iOS don't have a command key - "Ctrl K"
31
+ // reads more naturally there than the ⌘ glyph.
32
+ const kbd = trigger?.querySelector('.wd-search-kbd');
33
+ if (kbd && !/Mac|iPhone|iPad/.test(navigator.userAgent)) {
34
+ kbd.textContent = 'Ctrl K';
35
+ }
36
+
37
+ // Loaded lazily on first open rather than on every page load - most
38
+ // visits never open search, and the module + its wasm binary are pure
39
+ // overhead until someone actually wants to search. Pagefind only writes
40
+ // this file as a postbuild step, after Astro's own build (and therefore
41
+ // Vite's bundling) has already finished - see run-pagefind.js - so it
42
+ // never exists at `writedocs dev` time, and doesn't exist yet even
43
+ // during a production build's own Vite transform pass.
44
+ //
45
+ // `/* @vite-ignore */` alone doesn't stop Vite from trying to resolve it
46
+ // anyway: that comment only suppresses static analysis for a
47
+ // *non-literal* dynamic import specifier - a literal string like
48
+ // '/pagefind/pagefind.js' still gets resolved at transform time
49
+ // regardless of the comment, which crashes `writedocs dev` outright once
50
+ // this file exists in the template. Routing the literal through a
51
+ // variable first makes the specifier opaque to static analysis,
52
+ // deferring resolution to the browser at runtime - where the .catch()
53
+ // below handles "not built yet" gracefully instead.
54
+ let pagefind: any = null;
55
+ let loadPromise: Promise<any> | null = null;
56
+ function ensurePagefind() {
57
+ if (!loadPromise) {
58
+ // A page under a hidden navigation item searches its own space's index
59
+ // (cli/run-pagefind.js, lib/hidden-sections.js); every other page, the site's.
60
+ const space = document.querySelector<HTMLElement>('[data-wd-search-scope]')?.dataset.wdSearchSpace;
61
+ // Under writedocs.json's `basePath` ("" or "/docs", astro.config.mjs) -
62
+ // written into the strings so a site without one gets the same code.
63
+ const pagefindUrl = space ? `${__WD_BASE__}/pagefind-spaces/${encodeURIComponent(space)}/pagefind.js` : `${__WD_BASE__}/pagefind/pagefind.js`;
64
+ loadPromise = import(/* @vite-ignore */ pagefindUrl)
65
+ .then((mod: any) => {
66
+ pagefind = mod;
67
+ return mod.init();
68
+ })
69
+ .then(() => pagefind)
70
+ .catch(() => {
71
+ resultsEl.innerHTML =
72
+ '<div class="wd-search-empty">Search isn\'t available in this preview - run a full build to index it.</div>';
73
+ return null;
74
+ });
75
+ }
76
+ return loadPromise;
77
+ }
78
+
79
+ let currentResults: HTMLElement[] = [];
80
+ let activeIndex = -1;
81
+
82
+ // Down on the last result (or Up on the first) stays there - Enter always
83
+ // has a result to open.
84
+ function setActive(index: number) {
85
+ currentResults.forEach((el) => el.classList.remove('wd-search-result-active'));
86
+ activeIndex = currentResults.length ? Math.min(Math.max(index, 0), currentResults.length - 1) : -1;
87
+ if (activeIndex >= 0) {
88
+ currentResults[activeIndex].classList.add('wd-search-result-active');
89
+ currentResults[activeIndex].scrollIntoView({ block: 'nearest' });
90
+ }
91
+ }
92
+
93
+ // Search looks in the version, language and product of the page the reader
94
+ // is on (plus pages outside any of them), with a switch to search
95
+ // everything. [...slug].astro marks each page's scope for Pagefind and
96
+ // for this - see lib/search-scope.js.
97
+ let everything = false;
98
+ const pageScope = () => {
99
+ const el = document.querySelector<HTMLElement>('[data-wd-search-scope]');
100
+ const key = el?.dataset.wdSearchScope ?? 'all';
101
+ return key === 'all' ? null : { key, label: el?.dataset.wdSearchScopeLabel || key };
102
+ };
103
+ function scopeNote(scope: { label: string } | null, found: boolean) {
104
+ if (!scope) return null;
105
+ const note = document.createElement('div');
106
+ note.className = 'wd-search-scope';
107
+ const text = document.createElement('span');
108
+ const button = document.createElement('button');
109
+ button.type = 'button';
110
+ button.className = 'wd-search-scope-toggle';
111
+ if (everything) {
112
+ text.textContent = 'Showing results from the whole site.';
113
+ button.textContent = `Only ${scope.label}`;
114
+ } else {
115
+ text.textContent = found ? `Showing results in ${scope.label}.` : `No results in ${scope.label}.`;
116
+ button.textContent = 'Search everything';
117
+ }
118
+ button.addEventListener('click', (e) => {
119
+ e.stopPropagation();
120
+ everything = !everything;
121
+ input.focus();
122
+ runSearch(input.value);
123
+ });
124
+ note.append(text, ' ', button);
125
+ return note;
126
+ }
127
+
128
+ async function runSearch(term: string) {
129
+ if (!term.trim()) {
130
+ resultsEl.innerHTML = '<div class="wd-search-hint">Start typing to search...</div>';
131
+ currentResults = [];
132
+ activeIndex = -1;
133
+ return;
134
+ }
135
+ const pf = await ensurePagefind();
136
+ if (!pf) return;
137
+ // debouncedSearch resolves to null when a newer keystroke has already
138
+ // superseded this call - pagefind's own debounce, on top of (not
139
+ // instead of) the plain `input` listener below, so a fast typist never
140
+ // races two searches rendering out of order.
141
+ const scope = pageScope();
142
+ const options = scope && !everything ? { filters: { any: [{ scope: scope.key }, { scope: 'all' }] } } : {};
143
+ const search = await pf.debouncedSearch(term, options, 150);
144
+ if (search === null) return;
145
+ if (search.results.length === 0) {
146
+ resultsEl.innerHTML = '<div class="wd-search-empty">No results.</div>';
147
+ const note = scopeNote(scope, false);
148
+ if (note) resultsEl.replaceChildren(note);
149
+ currentResults = [];
150
+ activeIndex = -1;
151
+ return;
152
+ }
153
+ const entries = await Promise.all(search.results.slice(0, 12).map((r: any) => r.data()));
154
+ resultsEl.innerHTML = '';
155
+ for (const data of entries) {
156
+ const a = document.createElement('a');
157
+ a.className = 'wd-search-result';
158
+ a.href = data.url;
159
+ const title = document.createElement('div');
160
+ title.className = 'wd-search-result-title';
161
+ title.textContent = data.meta?.title ?? data.url;
162
+ // Where the page sits: "API Reference › Webhooks".
163
+ const section = data.meta?.section ? document.createElement('div') : null;
164
+ if (section) {
165
+ section.className = 'wd-search-result-section';
166
+ section.textContent = data.meta.section;
167
+ }
168
+ const excerpt = document.createElement('div');
169
+ excerpt.className = 'wd-search-result-excerpt';
170
+ // innerHTML (not textContent) is deliberate: pagefind returns this
171
+ // pre-sanitized with <mark> wrapping the matched terms, which is the
172
+ // whole point - a plain-text excerpt couldn't highlight anything.
173
+ // The section is indexed as the page's last words, so a short page's
174
+ // excerpt ends with it - shown once, on its own line, unless it's what
175
+ // matched (then the excerpt keeps it, highlighted).
176
+ const trailing = data.meta?.section ? ` ${data.meta.section}.` : null;
177
+ excerpt.innerHTML = trailing && data.excerpt.endsWith(trailing) ? data.excerpt.slice(0, -trailing.length) : data.excerpt;
178
+ a.append(title, ...(section ? [section] : []), excerpt);
179
+ resultsEl.appendChild(a);
180
+ }
181
+ const note = scopeNote(scope, true);
182
+ if (note) resultsEl.appendChild(note);
183
+ currentResults = Array.from(resultsEl.querySelectorAll('.wd-search-result'));
184
+ setActive(0);
185
+ }
186
+
187
+ function open() {
188
+ overlay.hidden = false;
189
+ document.body.style.overflow = 'hidden';
190
+ input.value = '';
191
+ everything = false;
192
+ resultsEl.innerHTML = '<div class="wd-search-hint">Start typing to search...</div>';
193
+ currentResults = [];
194
+ activeIndex = -1;
195
+ ensurePagefind();
196
+ input.focus();
197
+ }
198
+
199
+ function close() {
200
+ overlay.hidden = true;
201
+ document.body.style.overflow = '';
202
+ trigger?.focus();
203
+ }
204
+
205
+ trigger?.addEventListener('click', open);
206
+ overlay.addEventListener('click', (e) => {
207
+ if (e.target === overlay) close();
208
+ });
209
+ input.addEventListener('input', () => runSearch(input.value));
210
+ input.addEventListener('keydown', (e) => {
211
+ if (e.key === 'ArrowDown') {
212
+ e.preventDefault();
213
+ setActive(activeIndex + 1);
214
+ } else if (e.key === 'ArrowUp') {
215
+ e.preventDefault();
216
+ setActive(activeIndex - 1);
217
+ } else if (e.key === 'Enter' && activeIndex >= 0) {
218
+ currentResults[activeIndex]?.click();
219
+ } else if (e.key === 'Escape') {
220
+ close();
221
+ }
222
+ });
223
+ active = {
224
+ toggle: () => (overlay.hidden ? open() : close()),
225
+ closeIfOpen: () => {
226
+ if (!overlay.hidden) close();
227
+ },
228
+ };
229
+ if (!shortcutBound) {
230
+ shortcutBound = true;
231
+ document.addEventListener('keydown', (e) => {
232
+ if (!active) return;
233
+ if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) {
234
+ e.preventDefault();
235
+ active.toggle();
236
+ } else if (e.key === 'Escape') {
237
+ active.closeIfOpen();
238
+ }
239
+ });
240
+ }
241
+ }
@@ -705,6 +705,12 @@
705
705
  "description": "The site's address, like \"docs.example.com\". Turns on sitemap.xml and absolute URLs in link previews.",
706
706
  "markdownDescription": "The site's address, like \"docs.example.com\". Turns on sitemap.xml and absolute URLs in link previews."
707
707
  },
708
+ "basePath": {
709
+ "type": "string",
710
+ "pattern": "^(\\/|(\\/[a-z0-9_-]+)+)?$",
711
+ "description": "The path the site is served under, like \"/docs\" for example.com/docs - usually behind your own proxy. Every address the site makes starts with it, and the build writes the site to dist/docs/. Starts with \"/\", no \"/\" at the end; lowercase letters, digits, \"-\" and \"_\". Default: none, the site at the root.",
712
+ "markdownDescription": "The path the site is served under, like \"/docs\" for example.com/docs - usually behind your own proxy. Every address the site makes starts with it, and the build writes the site to dist/docs/. Starts with \"/\", no \"/\" at the end; lowercase letters, digits, \"-\" and \"_\". Default: none, the site at the root."
713
+ },
708
714
  "seo": {
709
715
  "default": {},
710
716
  "type": "object",