Skip to content

Fix single-word avatar initials#51

Merged
minimaldesign merged 1 commit into
mainfrom
fix-avatar-initials
Jul 24, 2026
Merged

Fix single-word avatar initials#51
minimaldesign merged 1 commit into
mainfrom
fix-avatar-initials

Conversation

@minimaldesign

Copy link
Copy Markdown
Owner

Problem

getInitials doubled the first letter of a one-word name, so an author of Yann rendered as YY on the blog index cards (all 20 of them).

With a single name, names[0] and names[names.length - 1] are the same array element, so the function concatenated the same character twice. The fullName.length <= 2 early return only shielded strings of two characters or fewer, so Yann fell through to the two-name path.

Fix

Single-word names now yield one initial. Two changes worth calling out:

  • Pre-computed initials still pass through. The length <= 2 branch is kept, because the avatar docs document <Avatar>SR</Avatar> as a supported way to hand the component initials directly. Without it, SR rendered as S.
  • The ":)" default is gone, replaced with an empty string.

Known limitation: a two-letter single name like Jo still returns JO, since it is indistinguishable from pre-computed initials. Separating the two cases would need an explicit prop.

Verification

Checked the rendered DOM on the dev server:

  • /blog: all 20 cards render Y (was YY).
  • /components/avatar: Sonny Rollins to SR, literal SR to SR, image variants unaffected.

🤖 Generated with Claude Code

getInitials doubled the first letter of a one-word name, so "Yann"
rendered as "YY" on the blog index cards. With one name, names[0] and
names[names.length - 1] are the same element; the length <= 2 early
return only covered strings of two characters or fewer.

Single-word names now yield one initial. Pre-computed initials like
"SR" still pass through untouched, which the avatar docs rely on. The
":)" default is gone, replaced with an empty string.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for mcssdev ready!

Name Link
🔨 Latest commit 3a4cddc
🔍 Latest deploy log https://app.netlify.com/projects/mcssdev/deploys/6a639b256c32770008dc76cc
😎 Deploy Preview https://deploy-preview-51--mcssdev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98
Accessibility: 98
Best Practices: 100
SEO: 99
PWA: 70
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@minimaldesign
minimaldesign merged commit c05b96f into main Jul 24, 2026
2 of 3 checks passed
@minimaldesign
minimaldesign deleted the fix-avatar-initials branch July 24, 2026 17:04
minimaldesign added a commit that referenced this pull request Jul 24, 2026
Retitle the Unreleased section to 1.1.0 and add the Fixed entries for
the single-word avatar initials fix (#51) and the random-function
preset-env polyfill being disabled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant