package main import ( "github.com/russross/blackfriday/v2" ) templ inbox_body(rcpt_addr string, ms []mail_obj) { nthmail.xyz

Emails for { rcpt_addr }:

} templ mail_comp(m mail_obj) {

From: { m.From } at { m.Date }

if m.To != "" {

To: { m.To }

} if m.Bcc != "" {

Bcc: { m.Bcc }

}

Subject: { m.Subject }

if m.MediaType == NotMultipart { for _, b := range m.Body { @body_plain(b.Data) } } else { if m.MediaType == Mixed { for _, b := range m.Body { switch b.MimeType { case PlainText: @body_plain(b.Data) case Html: @body_html(b.Data) case Markdown: @body_plain(b.Data) default: @body_plain(b.Data) } } } else { switch m.Body[m.PreferedBodyIndex].MimeType { case PlainText: @body_plain(m.Body[m.PreferedBodyIndex].Data) case Html: @body_html(m.Body[m.PreferedBodyIndex].Data) case Markdown: @body_markdown(m.Body[m.PreferedBodyIndex].Data) default: @body_plain(m.Body[m.PreferedBodyIndex].Data) } } } } templ body_plain(s string) {

{ s }

} templ body_html(s string) {

@templ.Raw(s)

} templ body_markdown(s string) { @body_html(string(blackfriday.Run([]byte(s)))) ) }