Skip to content

Commit 4d61ca0

Browse files
committed
change logic to look at githubcontent .md files instead of general site urls.
1 parent 7cc3995 commit 4d61ca0

File tree

1 file changed

+52
-12
lines changed

1 file changed

+52
-12
lines changed

src/theme/DocActionsDropdown/index.js

+52-12
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,60 @@ export default function DocActionsDropdown() {
8181
}
8282
};
8383

84-
const handleOpenInChatGPT = () => {
85-
const currentUrl = window.location.href;
86-
const prompt = `Analyze this Flow documentation page: ${currentUrl}. After reading, ask me what I'd like to know. Keep responses focused on the content.`;
87-
const encodedPrompt = encodeURIComponent(prompt);
88-
window.open(`https://chatgpt.com/?hints=search&q=${encodedPrompt}`, '_blank');
89-
setIsOpen(false);
84+
const handleOpenInChatGPT = async () => {
85+
try {
86+
const path = window.location.pathname.replace(/^\/docs\/?/, '').replace(/\/$/, '');
87+
const result = await fetchMarkdown(path);
88+
89+
if (result) {
90+
const prompt = `Analyze this documentation: ${result.url}. After reading, ask me what I'd like to know. Keep responses focused on the content.`;
91+
const encodedPrompt = encodeURIComponent(prompt);
92+
window.open(`https://chatgpt.com/?q=${encodedPrompt}`, '_blank');
93+
} else {
94+
// Fallback to current URL
95+
const currentUrl = window.location.href;
96+
const prompt = `Analyze this documentation: ${currentUrl}. After reading, ask me what I'd like to know. Keep responses focused on the content.`;
97+
const encodedPrompt = encodeURIComponent(prompt);
98+
window.open(`https://chatgpt.com/?q=${encodedPrompt}`, '_blank');
99+
}
100+
setIsOpen(false);
101+
} catch (error) {
102+
console.error('Error opening in ChatGPT:', error);
103+
// Fallback to current URL
104+
const currentUrl = window.location.href;
105+
const prompt = `Analyze this documentation: ${currentUrl}. After reading, ask me what I'd like to know. Keep responses focused on the content.`;
106+
const encodedPrompt = encodeURIComponent(prompt);
107+
window.open(`https://chatgpt.com/?q=${encodedPrompt}`, '_blank');
108+
setIsOpen(false);
109+
}
90110
};
91111

92-
const handleOpenInClaude = () => {
93-
const currentUrl = window.location.href;
94-
const prompt = `Review this Flow documentation page: ${currentUrl}. Once complete, ask me what questions I have. Stay focused on the provided content.`;
95-
const encodedPrompt = encodeURIComponent(prompt);
96-
window.open(`https://claude.ai/chat/new?prompt=${encodedPrompt}`, '_blank');
97-
setIsOpen(false);
112+
const handleOpenInClaude = async () => {
113+
try {
114+
const path = window.location.pathname.replace(/^\/docs\/?/, '').replace(/\/$/, '');
115+
const result = await fetchMarkdown(path);
116+
117+
if (result) {
118+
const prompt = `Review this documentation: ${result.url}. Once complete, ask me what questions I have. Stay focused on the provided content.`;
119+
const encodedPrompt = encodeURIComponent(prompt);
120+
window.open(`https://claude.ai/chat/new?prompt=${encodedPrompt}`, '_blank');
121+
} else {
122+
// Fallback to current URL
123+
const currentUrl = window.location.href;
124+
const prompt = `Review this documentation: ${currentUrl}. Once complete, ask me what questions I have. Stay focused on the provided content.`;
125+
const encodedPrompt = encodeURIComponent(prompt);
126+
window.open(`https://claude.ai/chat/new?prompt=${encodedPrompt}`, '_blank');
127+
}
128+
setIsOpen(false);
129+
} catch (error) {
130+
console.error('Error opening in Claude:', error);
131+
// Fallback to current URL
132+
const currentUrl = window.location.href;
133+
const prompt = `Review this documentation: ${currentUrl}. Once complete, ask me what questions I have. Stay focused on the provided content.`;
134+
const encodedPrompt = encodeURIComponent(prompt);
135+
window.open(`https://claude.ai/chat/new?prompt=${encodedPrompt}`, '_blank');
136+
setIsOpen(false);
137+
}
98138
};
99139

100140
const handleOpenFlowKnowledge = () => {

0 commit comments

Comments
 (0)