@@ -12,9 +12,6 @@ type PageActionOption = {
1212 id : string ;
1313 label : string ;
1414 icon : ReactNode ;
15- url ?: string ;
16- type : "copy" | "markdown" | "llm" ;
17- llmProvider ?: "openai" | "claude" ;
1815 ariaLabel ?: string ;
1916} ;
2017
@@ -29,33 +26,21 @@ const getPageActionOptions = (): PageActionOption[] => [
2926 id : "copy-page" ,
3027 label : "Copy Page" ,
3128 icon : < Copy /> ,
32- type : "copy" ,
33- ariaLabel : "Copy page content" ,
3429 } ,
3530 {
3631 id : "view-markdown" ,
3732 label : "View Markdown" ,
3833 icon : < Eye /> ,
39- type : "markdown" ,
40- ariaLabel : "View page as Markdown" ,
4134 } ,
4235 {
4336 id : "ask-chatgpt" ,
4437 label : "Ask in ChatGPT" ,
4538 icon : < OpenAiLogo /> ,
46- url : "https://chat.openai.com" ,
47- type : "llm" ,
48- llmProvider : "openai" ,
49- ariaLabel : "Ask in ChatGPT" ,
5039 } ,
5140 {
5241 id : "ask-claude" ,
5342 label : "Ask in Claude" ,
5443 icon : < ClaudeIcon /> ,
55- url : "https://claude.ai" ,
56- type : "llm" ,
57- llmProvider : "claude" ,
58- ariaLabel : "Ask in Claude" ,
5944 } ,
6045] ;
6146
@@ -74,8 +59,7 @@ export function PageActions({ content, title, url }: PageActionsProps) {
7459 }
7560
7661 function handleShare ( option : PageActionOption ) {
77- if ( option . type === "llm" && option . url ) {
78- const prompt = `Please read and analyze this documentation page:
62+ const prompt = `Please read and analyze this documentation page:
7963
8064 Title: ${ title }
8165 URL: ${ url }
@@ -85,27 +69,29 @@ export function PageActions({ content, title, url }: PageActionsProps) {
8569
8670 Please provide a summary and answer any questions I might have about this content.` ;
8771
88- const encodedInstruction = encodeURIComponent ( prompt ) ;
89- const shareUrl =
90- option . llmProvider === "claude"
91- ? `https://claude.ai/new?q=${ encodedInstruction } `
92- : `${ option . url } ?q=${ encodedInstruction } ` ;
72+ const encodedInstruction = encodeURIComponent ( prompt ) ;
9373
74+ if ( option . id === "ask-claude" ) {
75+ const shareUrl = `https://claude.ai/new?q=${ encodedInstruction } ` ;
76+ window . open ( shareUrl , "_blank" ) ;
77+ } else if ( option . id === "ask-chatgpt" ) {
78+ const shareUrl = `https://chat.openai.com?q=${ encodedInstruction } ` ;
9479 window . open ( shareUrl , "_blank" ) ;
9580 }
9681 }
9782
9883 function handleActionClick ( option : PageActionOption ) {
99- switch ( option . type ) {
100- case "copy" : {
84+ switch ( option . id ) {
85+ case "copy-page " : {
10186 copy ( ) ;
10287 break ;
10388 }
104- case "markdown" : {
89+ case "view- markdown" : {
10590 handleViewMarkdown ( ) ;
10691 break ;
10792 }
108- case "llm" : {
93+ case "ask-chatgpt" :
94+ case "ask-claude" : {
10995 handleShare ( option ) ;
11096 break ;
11197 }
@@ -117,7 +103,7 @@ export function PageActions({ content, title, url }: PageActionsProps) {
117103 < div className = { styles . container } >
118104 { pageActionOptions . map ( ( option , index ) => {
119105 const isLast = index === pageActionOptions . length - 1 ;
120- const isCopyAction = option . type === "copy" ;
106+ const isCopyAction = option . id === "copy-page " ;
121107 const showCheckIcon = isCopyAction && isCopied ;
122108
123109 return (
0 commit comments