Skip to content

Commit 925ee93

Browse files
authored
fix: make "Copy for LLMs" button work with query parameters in the URL (#2036)
Parses the current location as a URL before appending the `.md` suffix to route to the correct `md` URL. E.g. Hubspot adds those tracking query parameters, old code would add the `.md` suffix to the end of the query params. <img width="1286" height="229" alt="image" src="https://github.com/user-attachments/assets/95ed685a-09e2-4924-a0c8-62578cdef866" />
1 parent b596b88 commit 925ee93

File tree

1 file changed

+5
-1
lines changed
  • apify-docs-theme/src/theme/LLMButtons

1 file changed

+5
-1
lines changed

apify-docs-theme/src/theme/LLMButtons/index.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ const DROPDOWN_OPTIONS = [
5555
];
5656

5757
const getPrompt = (currentUrl) => `Read from ${currentUrl} so I can ask questions about it.`;
58-
const getMarkdownUrl = (currentUrl) => `${currentUrl}.md`;
58+
const getMarkdownUrl = (currentUrl) => {
59+
const url = new URL(currentUrl);
60+
url.pathname = `${url.pathname.replace(/\/$/, '')}.md`;
61+
return url.toString();
62+
};
5963

6064
const onOpenInChatGPTClick = () => {
6165
if (window.analytics) {

0 commit comments

Comments
 (0)