fix oauth

This commit is contained in:
2026-01-18 14:26:43 +09:00
parent 1fd619e32b
commit 6ef8780ac6
30 changed files with 3992 additions and 8 deletions

View File

@@ -0,0 +1,55 @@
import type { Profile } from '../types'
import { getAvatarUrl } from '../lib/api'
export async function renderProfile(
did: string,
profile: Profile,
handle: string,
webUrl?: string
): Promise<string> {
const avatarUrl = await getAvatarUrl(did, profile)
const displayName = profile.value.displayName || handle || 'Unknown'
const description = profile.value.description || ''
// Build profile link (e.g., https://bsky.app/profile/did:plc:xxx)
const profileLink = webUrl ? `${webUrl}/profile/${did}` : null
const handleHtml = profileLink
? `<a href="${profileLink}" class="profile-handle-link" target="_blank" rel="noopener">@${escapeHtml(handle)}</a>`
: `<span>@${escapeHtml(handle)}</span>`
const avatarHtml = avatarUrl
? `<a href="/"><img class="profile-avatar" src="${avatarUrl}" alt="${displayName}"></a>`
: `<a href="/"><div class="profile-avatar-placeholder"></div></a>`
return `
<div class="profile">
<div class="profile-row">
${avatarHtml}
<div class="profile-meta">
<span class="profile-name">${escapeHtml(displayName)}</span>
<span class="profile-handle">${handleHtml}</span>
</div>
</div>
${description ? `
<div class="profile-row">
<div class="profile-avatar-spacer"></div>
<p class="profile-description">${escapeHtml(description)}</p>
</div>
` : ''}
</div>
`
}
export function mountProfile(container: HTMLElement, html: string): void {
container.innerHTML = html
}
function escapeHtml(text: string): string {
return text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}