mirror of
https://github.com/aljazceru/njump.git
synced 2026-01-31 11:44:34 +01:00
Add cover image to long format notes
This commit is contained in:
6
data.go
6
data.go
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
1
pages.go
1
pages.go
@@ -196,6 +196,7 @@ type NotePageParams struct {
|
||||
|
||||
Details DetailsParams
|
||||
Content template.HTML
|
||||
Cover string
|
||||
Subject string
|
||||
TitleizedContent string
|
||||
Clients []ClientReference
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user