@apify/docs-theme 1.0.197 → 1.0.198
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/package.json +1 -1
- package/src/config.js +28 -28
- package/src/theme/SearchBar/index.js +188 -187
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -315,37 +315,37 @@ const plugins = [
|
|
|
315
315
|
];
|
|
316
316
|
|
|
317
317
|
const scripts = [
|
|
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
|
-
},
|
|
318
|
+
// {
|
|
319
|
+
// src: 'https://widget.kapa.ai/kapa-widget.bundle.js',
|
|
320
|
+
// 'data-website-id': 'a9937f98-9c9d-44d9-a433-fec4cb1c114d',
|
|
321
|
+
// 'data-project-name': 'Apify',
|
|
322
|
+
// 'data-modal-title': 'Apify AI Assistant',
|
|
323
|
+
// 'data-project-color': '#666666',
|
|
324
|
+
// 'data-button-hide': 'true',
|
|
325
|
+
// 'data-search-mode-enabled': 'true',
|
|
326
|
+
// 'data-search-include-source-names': '["Docs"]',
|
|
327
|
+
// 'data-project-logo': 'https://apify.com/img/apify-logo/logomark-32x32.svg',
|
|
328
|
+
// 'data-modal-example-questions': 'How to run an Actor?,Create a version of an Actor?',
|
|
329
|
+
// 'data-modal-override-open-id': 'ask-ai-input',
|
|
330
|
+
// 'data-modal-override-open-class': 'search-input',
|
|
331
|
+
// 'data-font-size-xs': '1.2rem',
|
|
332
|
+
// 'data-font-size-sm': '1.4rem',
|
|
333
|
+
// 'data-font-size-md': '1.6rem',
|
|
334
|
+
// 'data-font-size-lg': '1.8rem',
|
|
335
|
+
// 'data-font-size-xl': '2.0rem',
|
|
336
|
+
// async: true,
|
|
337
|
+
// },
|
|
338
|
+
// {
|
|
339
|
+
// src: 'https://cdn.jsdelivr.net/npm/@inkeep/cxkit-js@0.5/dist/embed.js',
|
|
340
|
+
// type: 'module',
|
|
341
|
+
// async: true,
|
|
342
|
+
// },
|
|
343
343
|
];
|
|
344
344
|
|
|
345
345
|
const customFields = {
|
|
346
|
-
inkeepApiKey: process.env.LOCALHOST || process.env.DEV
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
// inkeepApiKey: process.env.LOCALHOST || process.env.DEV
|
|
347
|
+
// ? 'bbbb9f1001a9b66f282431a80bb743a24e2bdefb85d4f1e4' // development, works with localhost
|
|
348
|
+
// : '8af30e40009f26622237f75aab8256064c26a3063717c48a', // production, only works on apify.com (any subdomain)
|
|
349
349
|
};
|
|
350
350
|
|
|
351
351
|
module.exports = {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// eslint-disable-next-line simple-import-sort/imports
|
|
2
2
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
3
3
|
import RouterLink from '@docusaurus/Link';
|
|
4
|
-
|
|
4
|
+
import { useHistory, useLocation } from '@docusaurus/router';
|
|
5
5
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
import React, { useEffect, useState } from 'react';
|
|
8
|
-
import {
|
|
6
|
+
// import clsx from 'clsx';
|
|
7
|
+
// import React, { useEffect, useState } from 'react';
|
|
8
|
+
import React, { useCallback } from 'react';
|
|
9
|
+
// import { useHotkeys } from 'react-hotkeys-hook';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
import { ControlKeyIcon, SearchIcon } from '@apify/docs-search-modal/dist/utils/icons';
|
|
11
|
+
import { ApifySearch } from '@apify/docs-search-modal';
|
|
12
|
+
// import { ControlKeyIcon, SearchIcon } from '@apify/docs-search-modal/dist/utils/icons';
|
|
12
13
|
|
|
13
14
|
// needs to be imported as the last thing, so that it can override the default styles
|
|
14
15
|
// TODO: update simple-import-sort to allow importing css as last.
|
|
@@ -43,201 +44,201 @@ export function Link(props) {
|
|
|
43
44
|
return <a {...props}>{props.children}</a>;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
// export default function SearchBar({ onClick }) {
|
|
47
|
-
// const { siteConfig } = useDocusaurusContext();
|
|
48
|
-
// const location = useLocation();
|
|
49
|
-
// const history = useHistory();
|
|
50
|
-
//
|
|
51
|
-
// const navigate = useCallback((href) => {
|
|
52
|
-
// const shortHref = href.substring('https://docs.apify.com'.length);
|
|
53
|
-
//
|
|
54
|
-
// if (matchesCurrentInstance(shortHref, siteConfig.baseUrl)) {
|
|
55
|
-
// return history.push(shortHref);
|
|
56
|
-
// }
|
|
57
|
-
// return window.location.assign(href);
|
|
58
|
-
// }, [history, siteConfig.baseUrl]);
|
|
59
|
-
//
|
|
60
|
-
// const getVersion = useCallback(() => {
|
|
61
|
-
// const match = location.pathname.match(/\/(\d+\.\d+|next)/);
|
|
62
|
-
//
|
|
63
|
-
// return match ? match[1] : 'latest';
|
|
64
|
-
// }, [location]);
|
|
65
|
-
//
|
|
66
|
-
// return (
|
|
67
|
-
// <BrowserOnly>
|
|
68
|
-
// {() => (
|
|
69
|
-
// <div onClick={onClick}>
|
|
70
|
-
// <ApifySearch
|
|
71
|
-
// algoliaAppId={siteConfig.themeConfig.algolia.appId}
|
|
72
|
-
// algoliaIndexName='apify_sdk_v2'
|
|
73
|
-
// algoliaKey={siteConfig.themeConfig.algolia.apiKey}
|
|
74
|
-
// filters={`version:${getVersion()}`}
|
|
75
|
-
// navigate={navigate}
|
|
76
|
-
// />
|
|
77
|
-
// </div>
|
|
78
|
-
// )}
|
|
79
|
-
// </BrowserOnly>
|
|
80
|
-
// );
|
|
81
|
-
// }
|
|
82
|
-
|
|
83
47
|
export default function SearchBar({ onClick }) {
|
|
84
|
-
const [variant, setVariant] = useState(null);
|
|
85
|
-
const [opened, setOpened] = useState(false);
|
|
86
48
|
const { siteConfig } = useDocusaurusContext();
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
const storedVariant = localStorage.getItem('search-provider');
|
|
91
|
-
|
|
92
|
-
if (storedVariant) {
|
|
93
|
-
setVariant(storedVariant);
|
|
94
|
-
} else {
|
|
95
|
-
const assignedVariant = Math.random() < 0.5 ? 'inkeep' : 'kapa';
|
|
96
|
-
localStorage.setItem('search-provider', assignedVariant);
|
|
97
|
-
setVariant(assignedVariant);
|
|
98
|
-
}
|
|
99
|
-
}, []);
|
|
49
|
+
const location = useLocation();
|
|
50
|
+
const history = useHistory();
|
|
100
51
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
52
|
+
const navigate = useCallback((href) => {
|
|
53
|
+
const shortHref = href.substring('https://docs.apify.com'.length);
|
|
105
54
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (variant === 'kapa') {
|
|
109
|
-
if (window.Kapa && typeof window.Kapa.open === 'function') {
|
|
110
|
-
window.Kapa.open();
|
|
111
|
-
window.Kapa('onModalClose', () => {
|
|
112
|
-
setOpened(false);
|
|
113
|
-
});
|
|
114
|
-
} else {
|
|
115
|
-
console.error('Kapa.ai widget is not available.');
|
|
116
|
-
}
|
|
117
|
-
return;
|
|
55
|
+
if (matchesCurrentInstance(shortHref, siteConfig.baseUrl)) {
|
|
56
|
+
return history.push(shortHref);
|
|
118
57
|
}
|
|
58
|
+
return window.location.assign(href);
|
|
59
|
+
}, [history, siteConfig.baseUrl]);
|
|
119
60
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
61
|
+
const getVersion = useCallback(() => {
|
|
62
|
+
const match = location.pathname.match(/\/(\d+\.\d+|next)/);
|
|
124
63
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
baseSettings: {
|
|
128
|
-
apiKey: inkeepApiKey,
|
|
129
|
-
organizationDisplayName: 'Apify',
|
|
130
|
-
primaryBrandColor: '#FF9013',
|
|
131
|
-
transformSource: (source) => {
|
|
132
|
-
function getTabForSource(src) {
|
|
133
|
-
if (src.url.includes('help.apify.com')) {
|
|
134
|
-
return 'Help';
|
|
135
|
-
}
|
|
136
|
-
return 'Docs';
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (source.contentType === 'documentation') {
|
|
140
|
-
return {
|
|
141
|
-
...source,
|
|
142
|
-
tabs: [...(source.tabs || []), getTabForSource(source)],
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
return source;
|
|
146
|
-
},
|
|
147
|
-
trigger: {
|
|
148
|
-
disableDefaultTrigger: true,
|
|
149
|
-
},
|
|
150
|
-
theme: {
|
|
151
|
-
styles: [
|
|
152
|
-
{
|
|
153
|
-
key: 'main',
|
|
154
|
-
type: 'link',
|
|
155
|
-
value: '/inkeep-overrides.css',
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
modalSettings: {
|
|
161
|
-
onOpenChange: handleOpenChange,
|
|
162
|
-
},
|
|
163
|
-
searchSettings: {
|
|
164
|
-
tabs: [
|
|
165
|
-
['Docs', { isAlwaysVisible: true }],
|
|
166
|
-
'GitHub',
|
|
167
|
-
'All',
|
|
168
|
-
],
|
|
169
|
-
},
|
|
170
|
-
aiChatSettings: {
|
|
171
|
-
aiAssistantAvatar: 'https://intercom.help/apify/assets/favicon',
|
|
172
|
-
chatSubjectName: 'Apify',
|
|
173
|
-
exampleQuestions: [
|
|
174
|
-
'What is an Actor?',
|
|
175
|
-
'How to use my own proxies?',
|
|
176
|
-
'How to integrate Apify Actors with GitHub?',
|
|
177
|
-
'How to share key-value stores between runs?',
|
|
178
|
-
],
|
|
179
|
-
getHelpOptions: [
|
|
180
|
-
{
|
|
181
|
-
action: {
|
|
182
|
-
type: 'open_link',
|
|
183
|
-
url: 'https://apify.com/contact',
|
|
184
|
-
},
|
|
185
|
-
icon: {
|
|
186
|
-
builtIn: 'IoChatbubblesOutline',
|
|
187
|
-
},
|
|
188
|
-
name: 'Contact Us',
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
defaultView: 'chat',
|
|
193
|
-
};
|
|
194
|
-
const modal = window.Inkeep.ModalSearchAndChat(config);
|
|
195
|
-
|
|
196
|
-
function handleOpenChange(newOpen) {
|
|
197
|
-
modal.update({ modalSettings: { isOpen: newOpen } });
|
|
198
|
-
setOpened(newOpen);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
modal.update({ modalSettings: { isOpen: true } });
|
|
202
|
-
} else {
|
|
203
|
-
console.error('Inkeep widget is not available.');
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const [key, setKey] = useState(null);
|
|
208
|
-
|
|
209
|
-
useEffect(() => {
|
|
210
|
-
if (typeof navigator !== 'undefined') {
|
|
211
|
-
const isMac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
212
|
-
setKey(isMac ? '⌘' : 'ctrl');
|
|
213
|
-
}
|
|
214
|
-
}, []);
|
|
215
|
-
|
|
216
|
-
useHotkeys('mod+k, /', () => {
|
|
217
|
-
onClick();
|
|
218
|
-
}, { preventDefault: true });
|
|
64
|
+
return match ? match[1] : 'latest';
|
|
65
|
+
}, [location]);
|
|
219
66
|
|
|
220
67
|
return (
|
|
221
68
|
<BrowserOnly>
|
|
222
69
|
{() => (
|
|
223
70
|
<div onClick={onClick}>
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
<kbd className={clsx(key === 'ctrl' ? 'ctrl' : 'cmd', 'DocSearch-Button-Key')}>
|
|
232
|
-
{key === 'ctrl' ? <ControlKeyIcon/> : key}
|
|
233
|
-
</kbd>
|
|
234
|
-
<kbd className="DocSearch-Button-Key">K</kbd>
|
|
235
|
-
</>)}
|
|
236
|
-
</span>
|
|
237
|
-
|
|
238
|
-
</button>
|
|
71
|
+
<ApifySearch
|
|
72
|
+
algoliaAppId={siteConfig.themeConfig.algolia.appId}
|
|
73
|
+
algoliaIndexName='apify_sdk_v2'
|
|
74
|
+
algoliaKey={siteConfig.themeConfig.algolia.apiKey}
|
|
75
|
+
filters={`version:${getVersion()}`}
|
|
76
|
+
navigate={navigate}
|
|
77
|
+
/>
|
|
239
78
|
</div>
|
|
240
79
|
)}
|
|
241
80
|
</BrowserOnly>
|
|
242
81
|
);
|
|
243
82
|
}
|
|
83
|
+
|
|
84
|
+
// export default function SearchBar({ onClick }) {
|
|
85
|
+
// const [variant, setVariant] = useState(null);
|
|
86
|
+
// const [opened, setOpened] = useState(false);
|
|
87
|
+
// const { siteConfig } = useDocusaurusContext();
|
|
88
|
+
// const { inkeepApiKey } = siteConfig.customFields;
|
|
89
|
+
//
|
|
90
|
+
// useEffect(() => {
|
|
91
|
+
// const storedVariant = localStorage.getItem('search-provider');
|
|
92
|
+
//
|
|
93
|
+
// if (storedVariant) {
|
|
94
|
+
// setVariant(storedVariant);
|
|
95
|
+
// } else {
|
|
96
|
+
// const assignedVariant = Math.random() < 0.5 ? 'inkeep' : 'kapa';
|
|
97
|
+
// localStorage.setItem('search-provider', assignedVariant);
|
|
98
|
+
// setVariant(assignedVariant);
|
|
99
|
+
// }
|
|
100
|
+
// }, []);
|
|
101
|
+
//
|
|
102
|
+
// onClick = () => {
|
|
103
|
+
// if (opened) {
|
|
104
|
+
// return;
|
|
105
|
+
// }
|
|
106
|
+
//
|
|
107
|
+
// setOpened(true);
|
|
108
|
+
//
|
|
109
|
+
// if (variant === 'kapa') {
|
|
110
|
+
// if (window.Kapa && typeof window.Kapa.open === 'function') {
|
|
111
|
+
// window.Kapa.open();
|
|
112
|
+
// window.Kapa('onModalClose', () => {
|
|
113
|
+
// setOpened(false);
|
|
114
|
+
// });
|
|
115
|
+
// } else {
|
|
116
|
+
// console.error('Kapa.ai widget is not available.');
|
|
117
|
+
// }
|
|
118
|
+
// return;
|
|
119
|
+
// }
|
|
120
|
+
//
|
|
121
|
+
// if (variant !== 'inkeep') {
|
|
122
|
+
// console.warn('Unknown search variant:', variant);
|
|
123
|
+
// return;
|
|
124
|
+
// }
|
|
125
|
+
//
|
|
126
|
+
// if (window.Inkeep) {
|
|
127
|
+
// const config = {
|
|
128
|
+
// baseSettings: {
|
|
129
|
+
// apiKey: inkeepApiKey,
|
|
130
|
+
// organizationDisplayName: 'Apify',
|
|
131
|
+
// primaryBrandColor: '#FF9013',
|
|
132
|
+
// transformSource: (source) => {
|
|
133
|
+
// function getTabForSource(src) {
|
|
134
|
+
// if (src.url.includes('help.apify.com')) {
|
|
135
|
+
// return 'Help';
|
|
136
|
+
// }
|
|
137
|
+
// return 'Docs';
|
|
138
|
+
// }
|
|
139
|
+
//
|
|
140
|
+
// if (source.contentType === 'documentation') {
|
|
141
|
+
// return {
|
|
142
|
+
// ...source,
|
|
143
|
+
// tabs: [...(source.tabs || []), getTabForSource(source)],
|
|
144
|
+
// };
|
|
145
|
+
// }
|
|
146
|
+
// return source;
|
|
147
|
+
// },
|
|
148
|
+
// trigger: {
|
|
149
|
+
// disableDefaultTrigger: true,
|
|
150
|
+
// },
|
|
151
|
+
// theme: {
|
|
152
|
+
// styles: [
|
|
153
|
+
// {
|
|
154
|
+
// key: 'main',
|
|
155
|
+
// type: 'link',
|
|
156
|
+
// value: '/inkeep-overrides.css',
|
|
157
|
+
// },
|
|
158
|
+
// ],
|
|
159
|
+
// },
|
|
160
|
+
// },
|
|
161
|
+
// modalSettings: {
|
|
162
|
+
// onOpenChange: handleOpenChange,
|
|
163
|
+
// },
|
|
164
|
+
// searchSettings: {
|
|
165
|
+
// tabs: [
|
|
166
|
+
// ['Docs', { isAlwaysVisible: true }],
|
|
167
|
+
// 'GitHub',
|
|
168
|
+
// 'All',
|
|
169
|
+
// ],
|
|
170
|
+
// },
|
|
171
|
+
// aiChatSettings: {
|
|
172
|
+
// aiAssistantAvatar: 'https://intercom.help/apify/assets/favicon',
|
|
173
|
+
// chatSubjectName: 'Apify',
|
|
174
|
+
// exampleQuestions: [
|
|
175
|
+
// 'What is an Actor?',
|
|
176
|
+
// 'How to use my own proxies?',
|
|
177
|
+
// 'How to integrate Apify Actors with GitHub?',
|
|
178
|
+
// 'How to share key-value stores between runs?',
|
|
179
|
+
// ],
|
|
180
|
+
// getHelpOptions: [
|
|
181
|
+
// {
|
|
182
|
+
// action: {
|
|
183
|
+
// type: 'open_link',
|
|
184
|
+
// url: 'https://apify.com/contact',
|
|
185
|
+
// },
|
|
186
|
+
// icon: {
|
|
187
|
+
// builtIn: 'IoChatbubblesOutline',
|
|
188
|
+
// },
|
|
189
|
+
// name: 'Contact Us',
|
|
190
|
+
// },
|
|
191
|
+
// ],
|
|
192
|
+
// },
|
|
193
|
+
// defaultView: 'chat',
|
|
194
|
+
// };
|
|
195
|
+
// const modal = window.Inkeep.ModalSearchAndChat(config);
|
|
196
|
+
//
|
|
197
|
+
// function handleOpenChange(newOpen) {
|
|
198
|
+
// modal.update({ modalSettings: { isOpen: newOpen } });
|
|
199
|
+
// setOpened(newOpen);
|
|
200
|
+
// }
|
|
201
|
+
//
|
|
202
|
+
// modal.update({ modalSettings: { isOpen: true } });
|
|
203
|
+
// } else {
|
|
204
|
+
// console.error('Inkeep widget is not available.');
|
|
205
|
+
// }
|
|
206
|
+
// };
|
|
207
|
+
//
|
|
208
|
+
// const [key, setKey] = useState(null);
|
|
209
|
+
//
|
|
210
|
+
// useEffect(() => {
|
|
211
|
+
// if (typeof navigator !== 'undefined') {
|
|
212
|
+
// const isMac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
213
|
+
// setKey(isMac ? '⌘' : 'ctrl');
|
|
214
|
+
// }
|
|
215
|
+
// }, []);
|
|
216
|
+
//
|
|
217
|
+
// useHotkeys('mod+k, /', () => {
|
|
218
|
+
// onClick();
|
|
219
|
+
// }, { preventDefault: true });
|
|
220
|
+
//
|
|
221
|
+
// return (
|
|
222
|
+
// <BrowserOnly>
|
|
223
|
+
// {() => (
|
|
224
|
+
// <div onClick={onClick}>
|
|
225
|
+
// <button type="button" className="DocSearch DocSearch-Button" aria-label="Search">
|
|
226
|
+
// <span className="DocSearch-Button-Container">
|
|
227
|
+
// <SearchIcon/>
|
|
228
|
+
// <span className="DocSearch-Button-Placeholder">Search</span>
|
|
229
|
+
// </span>
|
|
230
|
+
// <span className="DocSearch-Button-Keys">
|
|
231
|
+
// {key !== null && (<>
|
|
232
|
+
// <kbd className={clsx(key === 'ctrl' ? 'ctrl' : 'cmd', 'DocSearch-Button-Key')}>
|
|
233
|
+
// {key === 'ctrl' ? <ControlKeyIcon/> : key}
|
|
234
|
+
// </kbd>
|
|
235
|
+
// <kbd className="DocSearch-Button-Key">K</kbd>
|
|
236
|
+
// </>)}
|
|
237
|
+
// </span>
|
|
238
|
+
//
|
|
239
|
+
// </button>
|
|
240
|
+
// </div>
|
|
241
|
+
// )}
|
|
242
|
+
// </BrowserOnly>
|
|
243
|
+
// );
|
|
244
|
+
// }
|