@apify/docs-theme 1.0.187 → 1.0.189
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 +36 -1
- package/src/theme/Navbar/Content/index.jsx +2 -1
- package/src/theme/SearchBar/index.js +170 -22
- package/src/theme/custom.css +13 -0
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -132,7 +132,7 @@ const themeConfig = {
|
|
|
132
132
|
href: 'https://github.com/apify',
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
|
-
label: 'Actor
|
|
135
|
+
label: 'Actor whitepaper',
|
|
136
136
|
href: 'https://whitepaper.actor',
|
|
137
137
|
},
|
|
138
138
|
],
|
|
@@ -314,9 +314,44 @@ const plugins = [
|
|
|
314
314
|
},
|
|
315
315
|
];
|
|
316
316
|
|
|
317
|
+
const scripts = [
|
|
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-project-logo': 'https://apify.com/img/apify-logo/logomark-32x32.svg',
|
|
327
|
+
'data-modal-example-questions': 'How to run an Actor?,Create a version of an Actor?',
|
|
328
|
+
'data-modal-override-open-id': 'ask-ai-input',
|
|
329
|
+
'data-modal-override-open-class': 'search-input',
|
|
330
|
+
'data-font-size-xs': '1.2rem',
|
|
331
|
+
'data-font-size-sm': '1.4rem',
|
|
332
|
+
'data-font-size-md': '1.6rem',
|
|
333
|
+
'data-font-size-lg': '1.8rem',
|
|
334
|
+
'data-font-size-xl': '2.0rem',
|
|
335
|
+
async: true,
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
src: 'https://cdn.jsdelivr.net/npm/@inkeep/cxkit-js@0.5/dist/embed.js',
|
|
339
|
+
type: 'module',
|
|
340
|
+
async: true,
|
|
341
|
+
},
|
|
342
|
+
];
|
|
343
|
+
|
|
344
|
+
const customFields = {
|
|
345
|
+
inkeepApiKey: process.env.LOCALHOST || process.env.DEV
|
|
346
|
+
? 'bbbb9f1001a9b66f282431a80bb743a24e2bdefb85d4f1e4' // development, works with localhost
|
|
347
|
+
: '8af30e40009f26622237f75aab8256064c26a3063717c48a', // production, only works on apify.com (any subdomain)
|
|
348
|
+
};
|
|
349
|
+
|
|
317
350
|
module.exports = {
|
|
318
351
|
themeConfig,
|
|
319
352
|
plugins,
|
|
320
353
|
absoluteUrl,
|
|
321
354
|
noIndex,
|
|
355
|
+
scripts,
|
|
356
|
+
customFields,
|
|
322
357
|
};
|
|
@@ -8,9 +8,10 @@ import NavbarLogo from '@theme/Navbar/Logo';
|
|
|
8
8
|
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
|
|
9
9
|
import NavbarSearch from '@theme/Navbar/Search';
|
|
10
10
|
import NavbarItem from '@theme/NavbarItem';
|
|
11
|
+
import SearchBar from '@theme/SearchBar';
|
|
11
12
|
import React from 'react';
|
|
12
13
|
|
|
13
|
-
import SearchBar from '../../SearchBar';
|
|
14
|
+
// import SearchBar from '../../SearchBar';
|
|
14
15
|
import NavbarCTA from '../CTA';
|
|
15
16
|
|
|
16
17
|
function NavbarItems({ items }) {
|
|
@@ -1,11 +1,14 @@
|
|
|
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
|
-
import { useHistory, useLocation } from '@docusaurus/router';
|
|
4
|
+
// import { useHistory, useLocation } from '@docusaurus/router';
|
|
5
5
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
6
|
-
import
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
// import React, { useCallback } from 'react';
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
7
9
|
|
|
8
|
-
import { ApifySearch } from '@apify/docs-search-modal';
|
|
10
|
+
// import { ApifySearch } from '@apify/docs-search-modal';
|
|
11
|
+
import { ControlKeyIcon, SearchIcon } from '@apify/docs-search-modal/dist/utils/icons';
|
|
9
12
|
|
|
10
13
|
// needs to be imported as the last thing, so that it can override the default styles
|
|
11
14
|
// TODO: update simple-import-sort to allow importing css as last.
|
|
@@ -40,37 +43,182 @@ export function Link(props) {
|
|
|
40
43
|
return <a {...props}>{props.children}</a>;
|
|
41
44
|
}
|
|
42
45
|
|
|
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
|
+
|
|
43
83
|
export default function SearchBar({ onClick }) {
|
|
84
|
+
const [variant, setVariant] = useState(null);
|
|
44
85
|
const { siteConfig } = useDocusaurusContext();
|
|
45
|
-
const
|
|
46
|
-
|
|
86
|
+
const { inkeepApiKey } = siteConfig.customFields;
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const storedVariant = localStorage.getItem('search-provider');
|
|
90
|
+
|
|
91
|
+
if (storedVariant) {
|
|
92
|
+
setVariant(storedVariant);
|
|
93
|
+
} else {
|
|
94
|
+
const assignedVariant = Math.random() < 0.5 ? 'inkeep' : 'kapa';
|
|
95
|
+
localStorage.setItem('search-provider', assignedVariant);
|
|
96
|
+
setVariant(assignedVariant);
|
|
97
|
+
}
|
|
98
|
+
}, []);
|
|
47
99
|
|
|
48
|
-
|
|
49
|
-
|
|
100
|
+
onClick = () => {
|
|
101
|
+
if (variant === 'kapa') {
|
|
102
|
+
if (window.Kapa && typeof window.Kapa.open === 'function') {
|
|
103
|
+
window.Kapa.open();
|
|
104
|
+
} else {
|
|
105
|
+
console.error('Kapa.ai widget is not available.');
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
50
109
|
|
|
51
|
-
if (
|
|
52
|
-
|
|
110
|
+
if (variant !== 'inkeep') {
|
|
111
|
+
console.warn('Unknown search variant:', variant);
|
|
112
|
+
return;
|
|
53
113
|
}
|
|
54
|
-
return window.location.assign(href);
|
|
55
|
-
}, [history, siteConfig.baseUrl]);
|
|
56
114
|
|
|
57
|
-
|
|
58
|
-
|
|
115
|
+
if (window.Inkeep) {
|
|
116
|
+
const config = {
|
|
117
|
+
baseSettings: {
|
|
118
|
+
apiKey: inkeepApiKey,
|
|
119
|
+
organizationDisplayName: 'Apify',
|
|
120
|
+
primaryBrandColor: '#FF9013',
|
|
121
|
+
transformSource: (source) => {
|
|
122
|
+
if (source.contentType === 'documentation') {
|
|
123
|
+
return {
|
|
124
|
+
...source,
|
|
125
|
+
tabs: [...(source.tabs || []), 'Docs'],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return source;
|
|
129
|
+
},
|
|
130
|
+
trigger: {
|
|
131
|
+
disableDefaultTrigger: true,
|
|
132
|
+
},
|
|
133
|
+
theme: {
|
|
134
|
+
styles: [
|
|
135
|
+
{
|
|
136
|
+
key: 'main',
|
|
137
|
+
type: 'link',
|
|
138
|
+
value: '/inkeep-overrides.css',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
modalSettings: {
|
|
144
|
+
onOpenChange: handleOpenChange,
|
|
145
|
+
},
|
|
146
|
+
searchSettings: {
|
|
147
|
+
tabs: [
|
|
148
|
+
'All',
|
|
149
|
+
'Docs',
|
|
150
|
+
'Publications',
|
|
151
|
+
'PDFs',
|
|
152
|
+
'GitHub',
|
|
153
|
+
'Forums',
|
|
154
|
+
'Discord',
|
|
155
|
+
'Slack',
|
|
156
|
+
'StackOverflow',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
aiChatSettings: {
|
|
160
|
+
aiAssistantAvatar: 'https://intercom.help/apify/assets/favicon',
|
|
161
|
+
chatSubjectName: 'Apify',
|
|
162
|
+
exampleQuestions: [
|
|
163
|
+
'What is an Actor?',
|
|
164
|
+
'How to use my own proxies?',
|
|
165
|
+
'How to integrate Apify Actors with GitHub?',
|
|
166
|
+
'How to share key-value stores between runs?',
|
|
167
|
+
],
|
|
168
|
+
getHelpOptions: [
|
|
169
|
+
{
|
|
170
|
+
action: {
|
|
171
|
+
type: 'open_link',
|
|
172
|
+
url: 'https://apify.com/contact',
|
|
173
|
+
},
|
|
174
|
+
icon: {
|
|
175
|
+
builtIn: 'IoChatbubblesOutline',
|
|
176
|
+
},
|
|
177
|
+
name: 'Contact Us',
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
const modal = window.Inkeep.ModalSearchAndChat(config);
|
|
59
183
|
|
|
60
|
-
|
|
61
|
-
|
|
184
|
+
function handleOpenChange(newOpen) {
|
|
185
|
+
modal.update({ modalSettings: { isOpen: newOpen } });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
modal.update({ modalSettings: { isOpen: true } });
|
|
189
|
+
} else {
|
|
190
|
+
console.error('Inkeep widget is not available.');
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const [key, setKey] = useState(null);
|
|
195
|
+
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (typeof navigator !== 'undefined') {
|
|
198
|
+
const isMac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
199
|
+
setKey(isMac ? '⌘' : 'ctrl');
|
|
200
|
+
}
|
|
201
|
+
}, []);
|
|
62
202
|
|
|
63
203
|
return (
|
|
64
204
|
<BrowserOnly>
|
|
65
205
|
{() => (
|
|
66
206
|
<div onClick={onClick}>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
207
|
+
<button type="button" className="DocSearch DocSearch-Button" aria-label="Search">
|
|
208
|
+
<span className="DocSearch-Button-Container">
|
|
209
|
+
<SearchIcon/>
|
|
210
|
+
<span className="DocSearch-Button-Placeholder">Search</span>
|
|
211
|
+
</span>
|
|
212
|
+
<span className="DocSearch-Button-Keys">
|
|
213
|
+
{key !== null && (<>
|
|
214
|
+
<kbd className={clsx(key === 'ctrl' ? 'ctrl' : 'cmd', 'DocSearch-Button-Key')}>
|
|
215
|
+
{key === 'ctrl' ? <ControlKeyIcon/> : key}
|
|
216
|
+
</kbd>
|
|
217
|
+
<kbd className="DocSearch-Button-Key">K</kbd>
|
|
218
|
+
</>)}
|
|
219
|
+
</span>
|
|
220
|
+
|
|
221
|
+
</button>
|
|
74
222
|
</div>
|
|
75
223
|
)}
|
|
76
224
|
</BrowserOnly>
|
package/src/theme/custom.css
CHANGED
|
@@ -1984,3 +1984,16 @@ div[class^="navbarSearchContainer"] {
|
|
|
1984
1984
|
.medium-zoom-image--opened {
|
|
1985
1985
|
z-index: 999;
|
|
1986
1986
|
}
|
|
1987
|
+
|
|
1988
|
+
.DocSearch-Button {
|
|
1989
|
+
cursor: pointer;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
.DocSearch-Button-Key {
|
|
1993
|
+
border: 0;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
.DocSearch-Button-Key.ctrl:first-child {
|
|
1997
|
+
width: 14px !important;
|
|
1998
|
+
height: 15px !important;
|
|
1999
|
+
}
|