File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,13 @@ const pageTitle = entry?.data?.title || 'Documentation'
77const pageMarkdown = entry ?.body || ' '
88const pageUrl = Astro .url .href
99
10- // Construct GitHub URL for this page
10+ // API pages are auto-generated, so no GitHub source to link to
11+ const isApiPage = slug ?.startsWith (' api/' )
12+
13+ // Construct GitHub URL for this page (empty for API pages)
1114const githubBaseUrl = ' https://github.com/superfly/sprites-docs/blob/main/src/content/docs/'
1215const filePath = slug ? ` ${slug }.mdx ` : ' index.mdx'
13- const githubUrl = ` ${githubBaseUrl }${filePath } `
16+ const githubUrl = isApiPage ? ' ' : ` ${githubBaseUrl }${filePath } `
1417---
1518
1619<div class =" copy-page-button-wrapper" >
Original file line number Diff line number Diff line change @@ -242,7 +242,8 @@ export function CopyPageButton({
242242 </ span >
243243 </ DropdownMenuItem >
244244 < DropdownMenuItem
245- onClick = { ( ) => window . open ( githubUrl , '_blank' ) }
245+ onClick = { ( ) => githubUrl && window . open ( githubUrl , '_blank' ) }
246+ disabled = { ! githubUrl }
246247 className = "flex flex-col items-start gap-0.5 py-2"
247248 >
248249 < div className = "flex items-center gap-2" >
@@ -251,13 +252,20 @@ export function CopyPageButton({
251252 View on GitHub
252253 < VisuallyHidden > (opens in new tab)</ VisuallyHidden >
253254 </ span >
254- < ArrowUpRight className = "size-3 opacity-50" aria-hidden = "true" />
255+ { githubUrl && (
256+ < ArrowUpRight
257+ className = "size-3 opacity-50"
258+ aria-hidden = "true"
259+ />
260+ ) }
255261 </ div >
256262 < span
257263 className = "text-xs text-muted-foreground pl-6"
258264 aria-hidden = "true"
259265 >
260- View source on GitHub
266+ { githubUrl
267+ ? 'View source on GitHub'
268+ : 'Not available for generated pages' }
261269 </ span >
262270 </ DropdownMenuItem >
263271 </ DropdownMenuContent >
You can’t perform that action at this time.
0 commit comments