@apify/docs-theme 1.0.200 → 1.0.202

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/docs-theme",
3
- "version": "1.0.200",
3
+ "version": "1.0.202",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -0,0 +1,71 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import styles from '../styles.module.css';
4
+
5
+ // Custom component for button text
6
+ function ButtonText({ isLoading, isCopied }) {
7
+ if (isLoading) {
8
+ return 'Copying...';
9
+ }
10
+ if (isCopied) {
11
+ return 'Copied!';
12
+ }
13
+ return 'Copy for LLM';
14
+ }
15
+
16
+ export default function CopyForLLM() {
17
+ const [isLoading, setIsLoading] = useState(false);
18
+ const [isCopied, setIsCopied] = useState(false);
19
+
20
+ const handleCopy = async () => {
21
+ if (window.analytics) {
22
+ window.analytics.track('Clicked', {
23
+ app: 'docs',
24
+ button_text: 'Copy for LLM',
25
+ element: 'llm-buttons.copyForLLM',
26
+ });
27
+ }
28
+
29
+ try {
30
+ setIsLoading(true);
31
+
32
+ const currentUrl = window.location.href;
33
+ const markdownUrl = `${currentUrl}.md`;
34
+
35
+ // Fetch the markdown content
36
+ const response = await fetch(markdownUrl);
37
+
38
+ if (!response.ok) {
39
+ throw new Error(`Failed to fetch markdown: ${response.status}`);
40
+ }
41
+
42
+ const markdownContent = await response.text();
43
+
44
+ // Copy to clipboard
45
+ await navigator.clipboard.writeText(markdownContent);
46
+
47
+ // Show success feedback
48
+ setIsCopied(true);
49
+ setTimeout(() => setIsCopied(false), 2000);
50
+ } catch (error) {
51
+ console.error('Failed to copy markdown content:', error);
52
+ } finally {
53
+ setIsLoading(false);
54
+ }
55
+ };
56
+
57
+ return (
58
+ <button
59
+ className={styles.llmButton}
60
+ title="Copy for LLM"
61
+ onClick={handleCopy}
62
+ disabled={isLoading}
63
+ >
64
+ <span
65
+ className={`${styles.llmButtonIcon} ${styles.llmButtonIconBackgroundCopy}`}
66
+ aria-label="Copy for LLM"
67
+ />
68
+ <ButtonText isLoading={isLoading} isCopied={isCopied} />
69
+ </button>
70
+ );
71
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+
3
+ import styles from '../styles.module.css';
4
+
5
+ export default function ViewAsMarkdown() {
6
+ const handleClick = () => {
7
+ if (window.analytics) {
8
+ window.analytics.track('Clicked', {
9
+ app: 'docs',
10
+ button_text: 'View as Markdown',
11
+ element: 'llm-buttons.viewAsMarkdown',
12
+ });
13
+ }
14
+
15
+ try {
16
+ const currentUrl = window.location.href;
17
+ const markdownUrl = `${currentUrl}.md`;
18
+ window.open(markdownUrl, '_blank');
19
+ } catch (error) {
20
+ console.error('Error opening markdown file:', error);
21
+ }
22
+ };
23
+
24
+ return (
25
+ <button
26
+ className={styles.llmButton}
27
+ title="View as Markdown"
28
+ onClick={handleClick}
29
+ >
30
+ <span
31
+ className={`${styles.llmButtonIcon} ${styles.llmButtonIconBackgroundMarkdown}`}
32
+ aria-label="View as Markdown"
33
+ />
34
+ View as Markdown
35
+ </button>
36
+ );
37
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ import CopyForLLM from './CopyForLLM';
4
+ import styles from './styles.module.css';
5
+ import ViewAsMarkdown from './ViewAsMarkdown';
6
+
7
+ export default function LLMButtons() {
8
+ return (
9
+ <div className={styles.llmButtonsContainer}>
10
+ <ViewAsMarkdown />
11
+ <div className={styles.llmButtonsSeparator}></div>
12
+ <CopyForLLM />
13
+ </div>
14
+ );
15
+ }
@@ -0,0 +1,57 @@
1
+ .llmButtonsContainer {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 12px;
5
+ margin-top: -8px;
6
+ margin-bottom: calc(var(--ifm-h1-vertical-rhythm-bottom) * var(--ifm-leading));
7
+ }
8
+
9
+ .llmButtonsSeparator {
10
+ width: 1px;
11
+ height: 16px;
12
+ background-color: var(--ifm-hr-background-color);
13
+ }
14
+
15
+ .llmButton {
16
+ display: flex;
17
+ align-items: center;
18
+ background-color: transparent;
19
+ border: none;
20
+ height: 16px;
21
+ cursor: pointer;
22
+ padding: 0;
23
+ gap: 4px;
24
+ }
25
+
26
+ .llmButtonIcon {
27
+ width: 16px;
28
+ height: 16px;
29
+ margin: 0 !important;
30
+ cursor: pointer;
31
+ background-size: contain;
32
+ background-repeat: no-repeat;
33
+ background-position: center;
34
+ display: inline-block;
35
+ }
36
+
37
+ .llmButtonIconBackgroundMarkdown {
38
+ background-image: url('/img/markdown.svg');
39
+
40
+ }
41
+
42
+ .llmButtonIconBackgroundCopy {
43
+ background-image: url('/img/copy.svg');
44
+ }
45
+
46
+ /* Dark theme adjustments */
47
+ [data-theme='dark'] .llmButtonIcon {
48
+ color: #e0e0e0;
49
+ }
50
+
51
+ [data-theme='dark'] .llmButtonIconBackgroundMarkdown {
52
+ background-image: url('/img/markdown-dark-theme.svg');
53
+ }
54
+
55
+ [data-theme='dark'] .llmButtonIconBackgroundCopy {
56
+ background-image: url('/img/copy-dark-theme.svg');
57
+ }
@@ -1,5 +1,5 @@
1
- import LLMButtons from '@site/src/components/LLMButtons';
2
1
  import Admonition from '@theme/Admonition';
2
+ import LLMButtons from '@theme/LLMButtons';
3
3
  import MDXA from '@theme/MDXComponents/A';
4
4
  import MDXCode from '@theme/MDXComponents/Code';
5
5
  import MDXDetails from '@theme/MDXComponents/Details';