@@ -49,9 +49,14 @@ export const AskAi = () => {
4949 siteConfig : { url }
5050 } = useDocusaurusContext ( ) ;
5151
52- const markdownLink = `${ pathname } .md` ;
52+ // Some URL such as https://juno.build/docs/build/authentication/ ends with a slash
53+ const cleanPathname = pathname . replace ( / \/ + $ / , "" ) ;
5354
54- const prompt = encodeURIComponent ( `Read from this URL: ${ url } ${ pathname } ` ) ;
55+ const markdownLink = `${ cleanPathname } .md` ;
56+
57+ const prompt = encodeURIComponent (
58+ `Read from this URL: ${ url } ${ cleanPathname } `
59+ ) ;
5560 const claudeLink = `https://claude.ai/new?q=${ prompt } ` ;
5661 const chatGPTLink = `https://chatgpt.com/?prompt=${ prompt } ` ;
5762
@@ -72,7 +77,7 @@ export const AskAi = () => {
7277 < AskAiLink
7378 icon = { < IconMarkdown /> }
7479 link = { markdownLink }
75- pathname = { pathname }
80+ pathname = { cleanPathname }
7681 text = "View as Markdown"
7782 description = "Open this page in Markdown"
7883 eventName = "ask_ai_view_markdown"
@@ -81,7 +86,7 @@ export const AskAi = () => {
8186 < AskAiLink
8287 icon = { < IconClaude /> }
8388 link = { claudeLink }
84- pathname = { pathname }
89+ pathname = { cleanPathname }
8590 text = "Open in Claude"
8691 description = "Ask questions about this page"
8792 eventName = "ask_ai_claude"
@@ -90,7 +95,7 @@ export const AskAi = () => {
9095 < AskAiLink
9196 icon = { < IconOpenAI /> }
9297 link = { chatGPTLink }
93- pathname = { pathname }
98+ pathname = { cleanPathname }
9499 text = "Open in ChatGPT"
95100 description = "Ask questions about this page"
96101 eventName = "ask_ai_chatgpt"
0 commit comments