@@ -90,30 +90,23 @@ function CopyMarkdown() {
9090 ? currentPath . slice ( 0 , - 1 )
9191 : currentPath ;
9292
93- // Construct the markdown URL
94- const markdownUrl = `${ normalizedPath } .md` ;
93+ // Construct the full markdown URL with domain
94+ const fullMarkdownUrl = `https://docs.replicated.com ${ normalizedPath } .md` ;
9595
96- // Fetch the markdown content
97- const response = await fetch ( markdownUrl ) ;
96+ // Create the prompt to send to ChatGPT
97+ const prompt = `Read ${ fullMarkdownUrl } so I can ask questions about it` ;
9898
99- if ( ! response . ok ) {
100- throw new Error ( `Failed to fetch markdown: ${ response . status } ` ) ;
101- }
99+ // URL encode the prompt for the ChatGPT URL
100+ const encodedPrompt = encodeURIComponent ( prompt ) ;
102101
103- const markdown = await response . text ( ) ;
102+ // Create the ChatGPT URL with the prompt
103+ const chatGptUrl = `https://chat.openai.com/?prompt=${ encodedPrompt } ` ;
104104
105- // Open ChatGPT
106- const baseUrl = 'https://chat.openai.com/' ;
107- const newWindow = window . open ( baseUrl ) ;
105+ // Open ChatGPT with the prompt
106+ window . open ( chatGptUrl , '_blank' ) ;
108107
109- if ( newWindow ) {
110- // Copy to clipboard for pasting into ChatGPT
111- await navigator . clipboard . writeText ( markdown ) ;
112- setIsOpen ( false ) ;
113- // No visual feedback for this option
114- } else {
115- showToast ( 'Popup was blocked. Please allow popups for this site.' , true ) ;
116- }
108+ // Close the dropdown
109+ setIsOpen ( false ) ;
117110 } catch ( error ) {
118111 console . error ( 'Failed to open ChatGPT:' , error ) ;
119112 showToast ( 'Failed to open ChatGPT. Please try again.' , true ) ;
0 commit comments