Add cover image to long format notes

This commit is contained in:
dtonon
2024-05-30 22:31:00 +02:00
parent 961c674e5e
commit 261e1b8b38
4 changed files with 11 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ type Data struct {
video string
videoType string
image string
cover string
content string
alt string
kind1063Metadata *Kind1063Metadata
@@ -171,6 +172,11 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
}
data.kindNIP = kindNIPs[event.Kind]
image := event.Tags.GetFirst([]string{"image", ""})
if event.Kind == 30023 && image != nil {
data.cover = (*image)[1]
}
if event.Kind == 1063 {
if data.kind1063Metadata.IsImage() {
data.image = data.kind1063Metadata.URL

View File

@@ -18,6 +18,9 @@ templ noteTemplate(params NotePageParams) {
{ params.Metadata.ShortName() } on Nostr: { params.TitleizedContent }
</h1>
}
if params.Cover != "" {
<img src={ params.Cover } alt={ params.Alt } class="mt-1" />
}
<!-- main content -->
<div dir="auto" class="leading-5">
@templ.Raw(params.Content)

View File

@@ -196,6 +196,7 @@ type NotePageParams struct {
Details DetailsParams
Content template.HTML
Cover string
Subject string
TitleizedContent string
Clients []ClientReference

View File

@@ -386,6 +386,7 @@ func renderEvent(w http.ResponseWriter, r *http.Request) {
Clients: generateClientList(data.event.Kind, enhancedCode),
Details: detailsData,
Content: template.HTML(content),
Cover: data.cover,
Subject: subject,
TitleizedContent: titleizedContent,
})