mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
fix(frontend): give the embed snippet somewhere to paste.
The result screen ended at the snippet and a copy button. GitHub only renders a profile README from the repo named exactly after the account, and 15 of 23 arrivals did not have that repo, so the copy button was a dead end for most people. Add two links under the snippet: open the README, or create the repo. Also serve a placeholder card instead of a JSON 400 when someone pastes the README snippet without swapping YOUR_USERNAME for their own name, and show a live example card in the README. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BwMoSbmK77Ph7XaV5YnAdS
This commit is contained in:
@@ -34,6 +34,12 @@ export function ResultScreen({ username, generating, generatedSvg, generateError
|
||||
const fallbackUrl = `${window.location.origin}/api/${encodeURIComponent(username)}`
|
||||
const finalUrl = embedUrl || fallbackUrl
|
||||
const embedSnippet = `[](${window.location.origin})`
|
||||
// The snippet is useless without somewhere to paste it: GitHub only renders a
|
||||
// profile README from the repo named exactly after the account. Most people
|
||||
// arriving here don't have that repo yet, so offer both paths.
|
||||
const profileRepo = encodeURIComponent(username)
|
||||
const editReadmeUrl = `https://github.com/${profileRepo}/${profileRepo}/edit/main/README.md`
|
||||
const createRepoUrl = `https://github.com/new?name=${profileRepo}&description=${encodeURIComponent('My GitHub profile')}&visibility=public`
|
||||
|
||||
const copy = async () => {
|
||||
try {
|
||||
@@ -148,6 +154,12 @@ export function ResultScreen({ username, generating, generatedSvg, generateError
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
<p className="mt-3 text-xs text-gray-500">
|
||||
Paste it into <code className="text-gray-600">{username}/{username}</code>, the repo GitHub shows on your profile.{' '}
|
||||
<a href={editReadmeUrl} target="_blank" rel="noopener noreferrer" className="text-gray-700 underline hover:text-gray-900">Open your README</a>
|
||||
{' \u00b7 '}
|
||||
<a href={createRepoUrl} target="_blank" rel="noopener noreferrer" className="text-gray-700 underline hover:text-gray-900">Create the repo</a>
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user