@apify/docs-theme 1.0.216 → 1.0.218
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
CHANGED
|
@@ -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
|
+
|
|
@@ -2,6 +2,7 @@ import clsx from 'clsx';
|
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
AnthropicIcon,
|
|
5
6
|
ChatGptIcon,
|
|
6
7
|
CheckIcon,
|
|
7
8
|
ChevronDownIcon,
|
|
@@ -37,6 +38,13 @@ const DROPDOWN_OPTIONS = [
|
|
|
37
38
|
Icon: ChatGptIcon,
|
|
38
39
|
value: 'openInChatGPT',
|
|
39
40
|
},
|
|
41
|
+
{
|
|
42
|
+
label: 'Open in Claude',
|
|
43
|
+
description: 'Ask questions about this page',
|
|
44
|
+
showExternalIcon: true,
|
|
45
|
+
Icon: AnthropicIcon,
|
|
46
|
+
value: 'openInClaude',
|
|
47
|
+
},
|
|
40
48
|
{
|
|
41
49
|
label: 'Open in Perplexity',
|
|
42
50
|
description: 'Ask questions about this page',
|
|
@@ -70,6 +78,27 @@ const onOpenInChatGPTClick = () => {
|
|
|
70
78
|
}
|
|
71
79
|
};
|
|
72
80
|
|
|
81
|
+
const onOpenInClaudeClick = () => {
|
|
82
|
+
if (window.analytics) {
|
|
83
|
+
window.analytics.track('Clicked', {
|
|
84
|
+
app: 'docs',
|
|
85
|
+
button_text: 'Open in Claude',
|
|
86
|
+
element: 'llm-buttons.openInClaude',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const prompt = getPrompt(window.location.href);
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
window.open(
|
|
94
|
+
`https://claude.ai/new?q=${encodeURIComponent(prompt)}`,
|
|
95
|
+
'_blank',
|
|
96
|
+
);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error('Error opening Claude:', error);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
73
102
|
const onOpenInPerplexityClick = () => {
|
|
74
103
|
if (window.analytics) {
|
|
75
104
|
window.analytics.track('Clicked', {
|
|
@@ -227,6 +256,9 @@ export default function LLMButtons({ isApiReferencePage = false }) {
|
|
|
227
256
|
case 'openInChatGPT':
|
|
228
257
|
onOpenInChatGPTClick();
|
|
229
258
|
break;
|
|
259
|
+
case 'openInClaude':
|
|
260
|
+
onOpenInClaudeClick();
|
|
261
|
+
break;
|
|
230
262
|
case 'openInPerplexity':
|
|
231
263
|
onOpenInPerplexityClick();
|
|
232
264
|
break;
|