Skip to content

Commit b3010bb

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 b3010bb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-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: 6 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,15 @@ 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 className="size-3 opacity-50" aria-hidden="true" />
257+
)}
255258
</div>
256259
<span
257260
className="text-xs text-muted-foreground pl-6"
258261
aria-hidden="true"
259262
>
260-
View source on GitHub
263+
{githubUrl ? 'View source on GitHub' : 'Not available for generated pages'}
261264
</span>
262265
</DropdownMenuItem>
263266
</DropdownMenuContent>

0 commit comments

Comments
 (0)