-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
173 lines (154 loc) · 5.46 KB
/
index.tsx
File metadata and controls
173 lines (154 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import React, { type ReactNode } from 'react';
import Content from '@theme-original/DocItem/Content';
import type ContentType from '@theme/DocItem/Content';
import type { WrapperProps } from '@docusaurus/types';
function buildPathString(prefix = '', suffix = '') {
// Remove trailing slash from pathname
const cleanPath = window.location.pathname.replace(/\/$/, '');
return `${prefix}${cleanPath}${suffix}`;
}
function DocPageButtons() {
const buttonBase = {
display: "inline-flex",
alignItems: "center",
gap: "8px",
padding: "6px 12px",
fontSize: "14px",
borderWidth: "1px",
borderStyle: "solid",
borderColor: "#ccc",
backgroundColor: "#f9f9f9",
color: "#333",
cursor: "pointer",
transition: "all 0.2s ease",
userSelect: "none",
textAlign: "left",
};
const buttonHover = {
backgroundColor: "#eee",
};
const buttonGroup = {
display: "flex",
alignItems: "stretch",
marginBottom: "8px",
};
const buttonFirst = {
borderTopRightRadius: "0",
borderBottomRightRadius: "0",
borderTopLeftRadius: "20px",
borderBottomLeftRadius: "20px",
borderRight: "0",
};
const buttonMiddle = {
borderRadius: "0",
borderRight: "0",
};
const buttonLast = {
borderTopLeftRadius: "0",
borderBottomLeftRadius: "0",
borderTopRightRadius: "20px",
borderBottomRightRadius: "20px",
};
const [hoverIndex, setHoverIndex] = React.useState(-1);
// Share handler
const handleShare = () => {
const shareData = {
title: "Check this out",
text: "Here's a useful documentation page!",
url: window.location.href,
};
if (navigator.share) {
navigator.share(shareData).catch((err) => {
console.error("Share failed:", err.message);
});
} else {
window.location.href = `mailto:?subject=${encodeURIComponent(
shareData.title
)}&body=${encodeURIComponent(shareData.text + " " + shareData.url)}`;
}
};
const buttons = [
{
label: "Open in ChatGPT",
subLabel: "Ask ChatGPT about this page",
icon: "/img/icons/openai.svg",
onClick: () => {
const prefix = 'https://zeuz.ai';
const docURL = buildPathString(prefix);
const prompt = `Read ${docURL} and answer questions about the content`
const url = `https://chatgpt.com/?prompt=${prompt}`;
window.open(url, "_blank");
},
},
{
label: "Open in Claude",
subLabel: "Ask Claude about this page",
icon: "/img/icons/claude.svg",
onClick: () => {
const prefix = 'https://zeuz.ai';
const docURL = buildPathString(prefix);
const prompt = `Read ${docURL} and answer questions about the content`
const url = `https://claude.ai/new?q=${prompt}`;
window.open(url, "_blank");
},
},
{
label: "Share",
icon: "/img/icons/share.svg",
onClick: handleShare,
},
];
return (
<div style={buttonGroup}>
{buttons.map((btn, i) => {
let style = { ...buttonBase };
if (i === 0) style = { ...style, ...buttonFirst };
else if (i === buttons.length - 1) style = { ...style, ...buttonLast };
else style = { ...style, ...buttonMiddle };
if (hoverIndex === i) style = { ...style, ...buttonHover };
return (
<button
key={btn.label}
style={style}
onClick={btn.onClick}
onMouseEnter={() => setHoverIndex(i)}
onMouseLeave={() => setHoverIndex(-1)}
aria-label={btn.label}
>
{btn.icon ? (
<img
src={btn.icon}
alt={btn.label}
style={{
width: "20px",
height: "20px",
flexShrink: 0,
borderRadius: 0,
border: 'none',
boxShadow: 'none',
}}
/>
) : null}
<div style={{ display: "flex", flexDirection: "column", lineHeight: "1.2" }}>
<span style={{ fontWeight: 500 }}>{btn.label}</span>
{btn.subLabel ? (
<span style={{ fontSize: "12px", color: "#666" }}>
{btn.subLabel}
</span>
) : null}
</div>
</button>
);
})}
</div>
);
}
type Props = WrapperProps<typeof ContentType>;
export default function ContentWrapper(props: Props): ReactNode {
return (
<>
<DocPageButtons />
<Content {...props} />
</>
);
}