@apify/docs-theme 1.0.215 → 1.0.217
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 +3 -3
- package/src/config.js +15 -32
- package/src/theme/Heading/index.jsx +85 -0
- package/src/theme/Heading/styles.module.css +47 -0
- package/src/theme/SearchBar/index.js +38 -167
- package/src/theme/SearchBar/styles.css +37 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/docs-theme",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.217",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@apify/docs-search-modal": "^1.
|
|
23
|
-
"@apify/ui-library": "^1.97.2",
|
|
22
|
+
"@apify/docs-search-modal": "^1.3.3",
|
|
24
23
|
"@apify/ui-icons": "^1.19.0",
|
|
24
|
+
"@apify/ui-library": "^1.97.2",
|
|
25
25
|
"@docusaurus/theme-common": "^3.7.0",
|
|
26
26
|
"@stackql/docusaurus-plugin-hubspot": "^1.1.0",
|
|
27
27
|
"algoliasearch": "^5.19.0",
|
package/src/config.js
CHANGED
|
@@ -315,44 +315,27 @@ 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
|
-
// '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
|
-
// },
|
|
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-project-logo': 'https://apify.com/img/apify-logo/logomark-32x32.svg',
|
|
326
|
+
'data-modal-example-questions': 'How to run an Actor?,Create a version of an Actor?',
|
|
327
|
+
'data-modal-override-open-id': 'ask-ai-input',
|
|
328
|
+
'data-modal-override-open-class': 'search-input',
|
|
329
|
+
'data-scale-factor': '1.6',
|
|
330
|
+
'data-modal-size': '800px',
|
|
331
|
+
async: true,
|
|
332
|
+
},
|
|
343
333
|
];
|
|
344
334
|
|
|
345
|
-
const customFields = {
|
|
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
|
-
};
|
|
350
|
-
|
|
351
335
|
module.exports = {
|
|
352
336
|
themeConfig,
|
|
353
337
|
plugins,
|
|
354
338
|
absoluteUrl,
|
|
355
339
|
noIndex,
|
|
356
340
|
scripts,
|
|
357
|
-
customFields,
|
|
358
341
|
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useThemeConfig } from '@docusaurus/theme-common';
|
|
2
|
+
import { translate } from '@docusaurus/Translate';
|
|
3
|
+
import useBrokenLinks from '@docusaurus/useBrokenLinks';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import React, { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { LinkIcon } from '@apify/ui-icons';
|
|
8
|
+
import { useCopyToClipboard } from '@apify/ui-library';
|
|
9
|
+
|
|
10
|
+
import styles from './styles.module.css';
|
|
11
|
+
|
|
12
|
+
export default function Heading({ as: As, id, ...props }) {
|
|
13
|
+
const brokenLinks = useBrokenLinks();
|
|
14
|
+
const {
|
|
15
|
+
navbar: { hideOnScroll },
|
|
16
|
+
} = useThemeConfig();
|
|
17
|
+
|
|
18
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
19
|
+
|
|
20
|
+
// Register the anchor ID so Docusaurus can scroll to it
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (id) {
|
|
23
|
+
brokenLinks.collectAnchor(id);
|
|
24
|
+
|
|
25
|
+
// Handle scroll on page load if this heading matches the URL hash
|
|
26
|
+
const hash = decodeURIComponent(window.location.hash.slice(1));
|
|
27
|
+
if (hash === id) {
|
|
28
|
+
// Use setTimeout to ensure the page is fully rendered
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
const element = document.getElementById(id);
|
|
31
|
+
if (element) {
|
|
32
|
+
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
33
|
+
}
|
|
34
|
+
}, 100);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, [id, brokenLinks]);
|
|
38
|
+
|
|
39
|
+
// H1 headings and headings without an id shouldn't have the copy to clipboard button
|
|
40
|
+
if (As === 'h1' || !id) {
|
|
41
|
+
return <As {...props} {...(id && { id })} />;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const handleCopy = async (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
const url = new URL(window.location.href);
|
|
47
|
+
url.hash = `#${id ?? ''}`;
|
|
48
|
+
window.location.hash = `#${id ?? ''}`;
|
|
49
|
+
await copyToClipboard(url.toString());
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const anchorTitle = translate(
|
|
53
|
+
{
|
|
54
|
+
id: 'theme.common.headingLinkTitle',
|
|
55
|
+
message: 'Direct link to {heading}',
|
|
56
|
+
description: 'Title for link to heading',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
heading: typeof props.children === 'string' ? props.children : id,
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<As
|
|
65
|
+
{...props}
|
|
66
|
+
className={clsx(
|
|
67
|
+
'anchor',
|
|
68
|
+
hideOnScroll
|
|
69
|
+
? styles.anchorWithHideOnScrollNavbar
|
|
70
|
+
: styles.anchorWithStickyNavbar,
|
|
71
|
+
props.className,
|
|
72
|
+
)}
|
|
73
|
+
id={id}>
|
|
74
|
+
{props.children}
|
|
75
|
+
<a
|
|
76
|
+
onClick={handleCopy}
|
|
77
|
+
href={`#${id}`}
|
|
78
|
+
className={clsx(styles.headingCopyIcon, isCopied && styles.copied)}
|
|
79
|
+
aria-label={anchorTitle}
|
|
80
|
+
>
|
|
81
|
+
<LinkIcon size="16" />
|
|
82
|
+
</a>
|
|
83
|
+
</As>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.anchorWithStickyNavbar {
|
|
2
|
+
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.anchorWithHideOnScrollNavbar {
|
|
6
|
+
scroll-margin-top: 0.5rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.headingCopyIcon {
|
|
10
|
+
display: none;
|
|
11
|
+
position: relative;
|
|
12
|
+
left: .4rem;
|
|
13
|
+
color: var(--ifm-color-emphasis-700);
|
|
14
|
+
text-decoration: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.headingCopyIcon svg {
|
|
18
|
+
stroke: var(--ifm-color-primary);
|
|
19
|
+
max-height: 1em !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
h2:hover .headingCopyIcon,
|
|
23
|
+
h3:hover .headingCopyIcon,
|
|
24
|
+
h4:hover .headingCopyIcon,
|
|
25
|
+
h5:hover .headingCopyIcon,
|
|
26
|
+
h6:hover .headingCopyIcon {
|
|
27
|
+
display: inline-block;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.headingCopyIcon.copied {
|
|
31
|
+
display: inline-block !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.headingCopyIcon.copied svg {
|
|
35
|
+
display: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.headingCopyIcon.copied::after {
|
|
39
|
+
content: 'Copied!';
|
|
40
|
+
font-size: 12px;
|
|
41
|
+
color: var(--ifm-font-color-secondary);
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
margin-left: 8px;
|
|
44
|
+
vertical-align: middle;
|
|
45
|
+
line-height: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
@@ -3,13 +3,9 @@ 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
|
-
|
|
7
|
-
// import React, { useEffect, useState } from 'react';
|
|
8
|
-
import React, { useCallback } from 'react';
|
|
9
|
-
// import { useHotkeys } from 'react-hotkeys-hook';
|
|
6
|
+
import { useState, useCallback } from 'react';
|
|
10
7
|
|
|
11
8
|
import { ApifySearch } from '@apify/docs-search-modal';
|
|
12
|
-
// import { ControlKeyIcon, SearchIcon } from '@apify/docs-search-modal/dist/utils/icons';
|
|
13
9
|
|
|
14
10
|
// needs to be imported as the last thing, so that it can override the default styles
|
|
15
11
|
// TODO: update simple-import-sort to allow importing css as last.
|
|
@@ -67,7 +63,9 @@ export default function SearchBar({ onClick }) {
|
|
|
67
63
|
return (
|
|
68
64
|
<BrowserOnly>
|
|
69
65
|
{() => (
|
|
70
|
-
<div
|
|
66
|
+
<div className="SearchButton-Container">
|
|
67
|
+
|
|
68
|
+
<div onClick={onClick} className="AlgoliaContainer" style={{ marginRight: '12px' }}>
|
|
71
69
|
<ApifySearch
|
|
72
70
|
algoliaAppId={siteConfig.themeConfig.algolia.appId}
|
|
73
71
|
algoliaIndexName='apify_sdk_v2'
|
|
@@ -76,169 +74,42 @@ export default function SearchBar({ onClick }) {
|
|
|
76
74
|
navigate={navigate}
|
|
77
75
|
/>
|
|
78
76
|
</div>
|
|
77
|
+
<KapaAIButton />
|
|
78
|
+
</div>
|
|
79
79
|
)}
|
|
80
80
|
</BrowserOnly>
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
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
|
-
// 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
|
-
// }
|
|
84
|
+
function KapaAIButton({ onClick }) {
|
|
85
|
+
const [opened, setOpened] = useState(false);
|
|
86
|
+
|
|
87
|
+
onClick = () => {
|
|
88
|
+
if (opened) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setOpened(true);
|
|
93
|
+
|
|
94
|
+
if (window.Kapa && typeof window.Kapa.open === 'function') {
|
|
95
|
+
window.Kapa.open();
|
|
96
|
+
window.Kapa('onModalClose', () => {
|
|
97
|
+
setOpened(false);
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
console.error('Kapa.ai widget is not available.');
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<BrowserOnly>
|
|
106
|
+
{() => (
|
|
107
|
+
<div onClick={onClick}>
|
|
108
|
+
<button type="button" className="AskAI-Button" aria-label="Ask AI">
|
|
109
|
+
Ask AI
|
|
110
|
+
</button>
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
113
|
+
</BrowserOnly>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -22,20 +22,54 @@
|
|
|
22
22
|
color var(--ifm-transition-fast) var(--ifm-transition-timing-default);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.
|
|
25
|
+
.AskAI-Button {
|
|
26
|
+
height: 4rem;
|
|
27
|
+
padding: 0.8rem 1.6rem !important;
|
|
28
|
+
background-color: var(--ifm-color-primary);
|
|
29
|
+
border-radius: 8px;
|
|
30
|
+
color: var(--color-neutral-text-on-primary);
|
|
31
|
+
font-size: 1.6rem;
|
|
32
|
+
font-weight: 500;
|
|
33
|
+
line-height: 2.4rem;
|
|
34
|
+
border: none;
|
|
35
|
+
box-shadow: none;
|
|
36
|
+
outline: none;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
display: block;
|
|
40
|
+
position: relative;
|
|
41
|
+
text-align: center;
|
|
42
|
+
transition: all var(--ifm-transition-fast) var(--ifm-transition-timing-default);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.SearchButton-Container {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.navbar-sidebar .SearchButton-Container {
|
|
26
51
|
display: none;
|
|
27
52
|
}
|
|
28
53
|
|
|
29
54
|
@media (max-width: 768px) {
|
|
55
|
+
.SearchButton-Container {
|
|
56
|
+
width: 100%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.AlgoliaContainer {
|
|
60
|
+
flex: 1;
|
|
61
|
+
}
|
|
62
|
+
|
|
30
63
|
.DocSearch-Button {
|
|
31
64
|
width: 100%;
|
|
65
|
+
justify-content: space-between;
|
|
32
66
|
}
|
|
33
67
|
|
|
34
|
-
.navbar__inner .
|
|
68
|
+
.navbar__inner .SearchButton-Container {
|
|
35
69
|
display: none;
|
|
36
70
|
}
|
|
37
71
|
|
|
38
|
-
.navbar-sidebar .
|
|
72
|
+
.navbar-sidebar .SearchButton-Container {
|
|
39
73
|
display: flex;
|
|
40
74
|
}
|
|
41
75
|
|