Skip to content

Commit 91b7c81

Browse files
Kyle McLarenclaude
andcommitted
Disable View on GitHub for auto-generated API pages
API docs are generated from schema, not editable source files, so the GitHub link is disabled with explanatory text. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent ae0396a commit 91b7c81

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/CopyPageButton.astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ const pageTitle = entry?.data?.title || 'Documentation'
77
const pageMarkdown = entry?.body || ''
88
const 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)
1114
const githubBaseUrl = 'https://github.com/superfly/sprites-docs/blob/main/src/content/docs/'
1215
const 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">

src/components/react/CopyPageButton.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)