@writedocs/generator 0.7.1 → 0.7.3
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 +10 -4
- package/bin/writedocs.js +54 -16
- package/package.json +1 -1
- package/src/cli/build-auth.js +16 -9
- package/src/cli/build.js +3 -1
- package/src/cli/convert.js +6 -2
- package/src/cli/dev.js +7 -1
- package/src/cli/generate-api-pages.js +2 -2
- package/src/cli/init.js +3 -1
- package/src/cli/output.js +8 -1
- package/src/cli/preflight.js +63 -1
- package/src/cli/update-check-refresh.js +18 -0
- package/src/cli/update-check.js +104 -0
- package/src/cli/update.js +112 -0
- package/src/cli/write-redirects-file.js +2 -1
- package/src/components/ApiReferencePanel.astro +46 -12
- package/src/components/Steps.astro +2 -2
- package/src/layout/BaseLayout.astro +21 -6
- package/src/layout/styles/banner.css +1 -1
- package/src/lib/a11y-check.js +19 -42
- package/src/lib/asset-path.js +29 -0
- package/src/lib/color.js +49 -0
- package/src/lib/config-file.js +25 -0
- package/src/lib/config-schema.js +15 -12
- package/src/lib/config-schema.ts +20 -12
- package/src/lib/config.ts +18 -135
- package/src/lib/json-schema-descriptions.js +1 -1
- package/src/lib/mintlify-convert.js +2 -1
- package/src/lib/pages.js +121 -1
- package/src/lib/styles-asset-integration.js +1 -18
- package/src/lib/writedocs-legacy-convert.js +2 -1
- package/src/pages/[...slug].astro +11 -1
- package/src/pages/llms.txt.ts +5 -1
- package/src/scripts/search.ts +39 -14
- package/writedocs.schema.json +2 -2
package/src/scripts/search.ts
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
// SearchModal.astro's own trigger button (rendered inside TopBar.astro) +
|
|
2
2
|
// overlay/modal. Owns opening/closing the modal, the ⌘K/Ctrl K shortcut,
|
|
3
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
|
+
|
|
4
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.
|
|
5
17
|
const trigger = root.querySelector<HTMLButtonElement>('[data-search-trigger]');
|
|
6
18
|
const overlay = root.querySelector<HTMLElement>('#wd-search-overlay');
|
|
7
19
|
const input = root.querySelector<HTMLInputElement>('#wd-search-input');
|
|
8
20
|
const resultsEl = root.querySelector<HTMLElement>('#wd-search-results');
|
|
9
|
-
if (!
|
|
10
|
-
|
|
21
|
+
if (!overlay || !input || !resultsEl) {
|
|
22
|
+
active = null;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (overlay.dataset.wdInit) return;
|
|
26
|
+
overlay.dataset.wdInit = 'true';
|
|
11
27
|
|
|
12
28
|
// Most keyboards outside macOS/iOS don't have a command key - "Ctrl K"
|
|
13
29
|
// reads more naturally there than the ⌘ glyph.
|
|
14
|
-
const kbd = trigger
|
|
30
|
+
const kbd = trigger?.querySelector('.wd-search-kbd');
|
|
15
31
|
if (kbd && !/Mac|iPhone|iPad/.test(navigator.userAgent)) {
|
|
16
32
|
kbd.textContent = 'Ctrl K';
|
|
17
33
|
}
|
|
@@ -122,10 +138,10 @@ export function initSearch(root: ParentNode) {
|
|
|
122
138
|
function close() {
|
|
123
139
|
overlay.hidden = true;
|
|
124
140
|
document.body.style.overflow = '';
|
|
125
|
-
trigger
|
|
141
|
+
trigger?.focus();
|
|
126
142
|
}
|
|
127
143
|
|
|
128
|
-
trigger
|
|
144
|
+
trigger?.addEventListener('click', open);
|
|
129
145
|
overlay.addEventListener('click', (e) => {
|
|
130
146
|
if (e.target === overlay) close();
|
|
131
147
|
});
|
|
@@ -143,13 +159,22 @@ export function initSearch(root: ParentNode) {
|
|
|
143
159
|
close();
|
|
144
160
|
}
|
|
145
161
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (overlay.hidden)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
active = {
|
|
163
|
+
toggle: () => (overlay.hidden ? open() : close()),
|
|
164
|
+
closeIfOpen: () => {
|
|
165
|
+
if (!overlay.hidden) close();
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
if (!shortcutBound) {
|
|
169
|
+
shortcutBound = true;
|
|
170
|
+
document.addEventListener('keydown', (e) => {
|
|
171
|
+
if (!active) return;
|
|
172
|
+
if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
active.toggle();
|
|
175
|
+
} else if (e.key === 'Escape') {
|
|
176
|
+
active.closeIfOpen();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
155
180
|
}
|
package/writedocs.schema.json
CHANGED
|
@@ -692,8 +692,8 @@
|
|
|
692
692
|
"proxy": {
|
|
693
693
|
"default": true,
|
|
694
694
|
"type": "boolean",
|
|
695
|
-
"description": "
|
|
696
|
-
"markdownDescription": "
|
|
695
|
+
"description": "When the browser blocks a \"Try it\" request (the API doesn't allow calls from other sites - CORS), retry it through writedocs' proxy. Requests always go to the API directly first. Default true.",
|
|
696
|
+
"markdownDescription": "When the browser blocks a \"Try it\" request (the API doesn't allow calls from other sites - CORS), retry it through writedocs' proxy. Requests always go to the API directly first. Default true."
|
|
697
697
|
}
|
|
698
698
|
},
|
|
699
699
|
"additionalProperties": false,
|