This commit is contained in:
2026-01-16 01:42:31 +09:00
parent 4731d64b4d
commit 1728f8dd35
13 changed files with 358 additions and 25 deletions

View File

@@ -1,18 +1,23 @@
import type { Profile } from '../types.js'
import { escapeHtml } from '../lib/utils.js'
export function renderProfile(profile: Profile): string {
export function renderProfile(profile: Profile, webUrl?: string): string {
const profileLink = webUrl ? `${webUrl}/profile/${profile.did}` : null
const handleHtml = profileLink
? `<a href="${escapeHtml(profileLink)}" class="profile-handle-link" target="_blank" rel="noopener">@${escapeHtml(profile.handle)}</a>`
: `@${escapeHtml(profile.handle)}`
return `
<div class="profile">
${profile.avatar ? `<img src="${profile.avatar}" alt="avatar" class="profile-avatar">` : ''}
${profile.avatar ? `<img src="${escapeHtml(profile.avatar)}" alt="avatar" class="profile-avatar">` : ''}
<div class="profile-info">
<h1 class="profile-name">${profile.displayName || profile.handle}</h1>
<p class="profile-handle">@${profile.handle}</p>
${profile.description ? `<p class="profile-desc">${profile.description}</p>` : ''}
<h1 class="profile-name">${escapeHtml(profile.displayName || profile.handle)}</h1>
<p class="profile-handle">${handleHtml}</p>
${profile.description ? `<p class="profile-desc">${escapeHtml(profile.description)}</p>` : ''}
</div>
</div>
`
}
export function mountProfile(container: HTMLElement, profile: Profile): void {
container.innerHTML = renderProfile(profile)
export function mountProfile(container: HTMLElement, profile: Profile, webUrl?: string): void {
container.innerHTML = renderProfile(profile, webUrl)
}