Skip to content

Commit 9c4b254

Browse files
committed
Fix markdownPageURL for PageActions
1 parent d74f8a7 commit 9c4b254

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.changeset/eight-eels-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Fix markdownPageURL for PageActions

packages/gitbook/src/components/PageActions/PageActions.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ export function ActionOpenInLLM(props: {
171171

172172
const providerLabel = provider === 'chatgpt' ? 'ChatGPT' : 'Claude';
173173

174+
// Remove the .md extension from the URL to avoid sending a bad request to the LLM.
175+
const urlWithoutExtension = url.replace(/\.md$/, '');
176+
174177
return (
175178
<PageActionWrapper
176179
type={type}
177180
icon={provider}
178181
label={tString(language, 'open_in', providerLabel)}
179182
shortLabel={providerLabel}
180183
description={tString(language, 'ai_chat_ask_about_page', providerLabel)}
181-
href={getLLMURL(provider, url, language)}
184+
href={getLLMURL(provider, urlWithoutExtension, language)}
182185
/>
183186
);
184187
}

packages/gitbook/src/components/PageBody/PageHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function PageHeader(props: {
4040
// Show page actions if *any* of the actions are enabled
4141
<PageActionsDropdown
4242
siteTitle={context.site.title}
43-
markdownPageURL={`${context.linker.toAbsoluteURL(context.linker.toPathInSpace(page.path))}`}
43+
markdownPageURL={`${context.linker.toAbsoluteURL(context.linker.toPathInSpace(page.path))}.md`}
4444
editOnGit={
4545
context.customization.git.showEditLink &&
4646
context.space.gitSync?.url &&

0 commit comments

Comments
 (0)