Skip to content

Commit fe8ef82

Browse files
committed
Fix username display
1 parent d3b7a83 commit fe8ef82

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

docs/js/github-profiles.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ document.addEventListener('DOMContentLoaded', function() {
1010
if (text.startsWith('@')) {
1111
const username = text.substring(1);
1212
if (username && username.length > 0) {
13-
// Replace cell content with a profile link
14-
cell.innerHTML = `<span class="github-handle" data-username="${username}">@${username}</span>`;
13+
// Just use the span without displaying the handle again (will be shown in card)
14+
cell.innerHTML = `<span class="github-handle" data-username="${username}"></span>`;
1515
}
1616
}
1717
});
@@ -38,7 +38,7 @@ document.addEventListener('DOMContentLoaded', function() {
3838

3939
// Replace all instances of GitHub handles with profile cards
4040
element.innerHTML = text.replace(pattern, function(match, prefix, username) {
41-
return `${prefix}<span class="github-handle" data-username="${username}">@${username}</span>`;
41+
return `${prefix}<span class="github-handle" data-username="${username}"></span>`;
4242
});
4343
});
4444

@@ -54,7 +54,7 @@ document.addEventListener('DOMContentLoaded', function() {
5454
cardContainer.className = 'github-profile-card';
5555

5656
// Add loading indicator
57-
cardContainer.innerHTML = `<div class="loading">Loading @${username}'s profile...</div>`;
57+
cardContainer.innerHTML = `<div class="loading">Loading GitHub profile...</div>`;
5858

5959
// Insert card after the handle
6060
handle.parentNode.insertBefore(cardContainer, handle.nextSibling);
@@ -76,16 +76,19 @@ document.addEventListener('DOMContentLoaded', function() {
7676
return response.json();
7777
})
7878
.then(data => {
79-
// Create profile card with GitHub data - just use handle if no name
79+
// Create profile card with GitHub data - use real name if available, with handle underneath
80+
const displayName = data.name || username;
81+
8082
cardContainer.innerHTML = `
8183
<div class="profile-card">
8284
<div class="profile-image">
8385
<a href="${data.html_url}" target="_blank">
84-
<img src="${data.avatar_url}" alt="@${username}'s avatar">
86+
<img src="${data.avatar_url}" alt="${displayName}'s avatar">
8587
</a>
8688
</div>
8789
<div class="profile-info">
88-
<h4><a href="${data.html_url}" target="_blank">@${username}</a></h4>
90+
<h4><a href="${data.html_url}" target="_blank">${displayName}</a></h4>
91+
<p class="username">@${username}</p>
8992
${data.bio ? `<p class="bio">${data.bio}</p>` : ''}
9093
</div>
9194
</div>
@@ -122,8 +125,13 @@ document.addEventListener('DOMContentLoaded', function() {
122125
.profile-info h4 {
123126
margin: 0 0 5px 0;
124127
}
128+
.profile-info .username {
129+
margin: 0 0 5px 0;
130+
font-size: 0.8em;
131+
color: #586069;
132+
}
125133
.profile-info .bio {
126-
margin: 0;
134+
margin: 5px 0 0 0;
127135
font-size: 0.9em;
128136
color: #586069;
129137
}

0 commit comments

Comments
 (0)