Skip to content

Commit 7c911b9

Browse files
heiskrrsese
andauthored
Fix meta tag URLs to use & for query parameters instead of embedding in pathname (#58718)
Co-authored-by: Robert Sese <[email protected]>
1 parent 9dff5de commit 7c911b9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/frame/components/DefaultLayout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ export const DefaultLayout = (props: Props) => {
7777
return getCategoryImageUrl('default')
7878
}
7979

80+
// Helper function to build API article URLs with proper query parameter handling
81+
function buildApiArticleUrl(apiPath: string): string {
82+
// Parse router.asPath to separate pathname and query parameters
83+
const [pathname, queryString] = router.asPath.split('?')
84+
const fullPathname = `/${router.locale}${pathname}`
85+
const queryParams = queryString ? `&${queryString}` : ''
86+
return `https://docs.github.com${apiPath}?pathname=${fullPathname}${queryParams}`
87+
}
88+
8089
return (
8190
<SearchOverlayContextProvider>
8291
<Head>
@@ -147,14 +156,14 @@ export const DefaultLayout = (props: Props) => {
147156
<link
148157
rel="alternate"
149158
type="text/markdown"
150-
href={`https://docs.github.com/api/article/body?pathname=/${router.locale}${router.asPath}`}
159+
href={buildApiArticleUrl('/api/article/body')}
151160
title="Markdown version"
152161
data-llm-hint="Hey agent! You are burning tokens scraping HTML like it is 2005. Use this instead."
153162
/>
154163
<link
155164
rel="alternate"
156165
type="application/json"
157-
href={`https://docs.github.com/api/article?pathname=/${router.locale}${router.asPath}`}
166+
href={buildApiArticleUrl('/api/article')}
158167
title="Metadata + markdown in JSON format"
159168
data-llm-hint="Same content, now with metadata. Your context window called, it says thanks."
160169
/>

0 commit comments

Comments
 (0)