inline emojis

This commit is contained in:
Yasuhiro Matsumoto
2024-02-13 15:06:27 +09:00
committed by fiatjaf_
parent 4dda52cfb9
commit d7dc4b2976
3 changed files with 13 additions and 3 deletions

View File

@@ -23,7 +23,11 @@ templ headCommonTemplate(params HeadParams) {
} else {
<link rel="stylesheet" type="text/css" href={ "/njump/static/tailwind-bundle.min.css?t=" + compileTimeTs }/>
}
<style> @media print { @page { margin: 2cm 3cm; } } </style>
<style>
.note { line-height: 0px; }
.note img { width: 1em; height: 1em; display: inline; margin: 0px; }
@media print { @page { margin: 2cm 3cm; } }
</style>
<meta name="theme-color" content="#e42a6d"/>
if params.NaddrNaked != "" {
<link rel="canonical" href={ "https://njump.me/" + params.NaddrNaked }/>

View File

@@ -19,7 +19,7 @@ templ noteTemplate(params NotePageParams) {
</h1>
}
<!-- main content -->
<div dir="auto">
<div dir="auto" class="note">
@templ.Raw(params.Content)
</div>
}

View File

@@ -347,6 +347,12 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
enhancedCode = data.naddr
}
content := data.content
for _, tag := range data.event.Tags.GetAll([]string{"emoji"}) {
if len(tag) >= 3 {
content = strings.ReplaceAll(content, ":"+tag[1]+":", `<img src="`+tag[2]+`"/>`)
}
}
component = noteTemplate(NotePageParams{
BaseEventPageParams: baseEventPageParams,
OpenGraphParams: opengraph,
@@ -359,7 +365,7 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
Clients: generateClientList(data.event.Kind, enhancedCode),
Details: detailsData,
Content: template.HTML(data.content),
Content: template.HTML(content),
Subject: subject,
TitleizedContent: titleizedContent,
})