package components import ( "crypto/md5" "fmt" "strings" "html/template" "github.com/logto-io/go/core" ) var GravatarTemplate = template.Must(template.New("gravatar").Parse("
")) func GetGravatarURL(email string, size uint) string { email = strings.TrimSpace(strings.ToLower(email)) hash := md5.Sum([]byte(email)) gravatarURL := fmt.Sprintf("https://www.gravatar.com/avatar/%x?s=%d", hash, size) return string(templ.URL(gravatarURL)) } templ User(claims *core.IdTokenClaims) {
@templ.FromGoHTML(GravatarTemplate, GetGravatarURL(claims.Email, 100))
}