@@ -113,11 +113,7 @@ export function CopyPageDropdown({
113113 const [ copied , setCopied ] = React . useState ( false )
114114 const { notify } = useToast ( )
115115
116- // Determine if we should fetch from GitHub or use the page URL
117- const useGitHub = repo === 'tanstack/tanstack.com'
118- const gitHubUrl = useGitHub
119- ? `https://raw.githubusercontent.com/${ repo } /${ branch } /${ filePath } `
120- : null
116+ // For docs pages in this repo, prefer the site's markdown endpoint so requests stay behind site caching.
121117 const pageMarkdownUrl = ( ( ) => {
122118 const base = `${ typeof window !== 'undefined' ? window . location . origin : '' } ${ typeof window !== 'undefined' ? window . location . pathname . replace ( / \/ $ / , '' ) : '' } .md`
123119 const params = new URLSearchParams ( )
@@ -134,6 +130,13 @@ export function CopyPageDropdown({
134130 return queryString ? `${ base } ?${ queryString } ` : base
135131 } ) ( )
136132
133+ const sourceMarkdownUrl =
134+ repo === 'tanstack/tanstack.com'
135+ ? pageMarkdownUrl
136+ : repo && branch && filePath
137+ ? `https://raw.githubusercontent.com/${ repo } /${ branch } /${ filePath } `
138+ : pageMarkdownUrl
139+
137140 const handleCopyPage = async ( ) => {
138141 if ( rawContent ) {
139142 await navigator . clipboard . writeText ( rawContent )
@@ -147,7 +150,7 @@ export function CopyPageDropdown({
147150 return
148151 }
149152
150- const urlToFetch = gitHubUrl || pageMarkdownUrl
153+ const urlToFetch = sourceMarkdownUrl
151154 const cached = markdownCache . get ( urlToFetch )
152155
153156 const copyContent = async ( content : string , source : string ) => {
@@ -176,9 +179,9 @@ export function CopyPageDropdown({
176179 markdownCache . set ( urlToFetch , content )
177180 await copyContent (
178181 content ,
179- gitHubUrl
180- ? 'Markdown content copied from GitHub '
181- : 'Markdown content copied' ,
182+ repo === 'tanstack/tanstack.com'
183+ ? 'Markdown content copied from markdown endpoint '
184+ : 'Markdown content copied from GitHub ' ,
182185 )
183186 } catch {
184187 // Fallback: try to copy current page content if available
@@ -204,7 +207,7 @@ export function CopyPageDropdown({
204207 }
205208
206209 const handleViewMarkdown = ( ) => {
207- const url = gitHubUrl || pageMarkdownUrl
210+ const url = sourceMarkdownUrl
208211 window . open ( url , '_blank' )
209212 }
210213
0 commit comments