diff --git a/pages.go b/pages.go index ab59f6a..7d93588 100644 --- a/pages.go +++ b/pages.go @@ -120,6 +120,26 @@ func (*TelegramInstantViewPage) TemplateText() string { return tmplTelegramInstantView } +var ( + //go:embed templates/homepage.html + tmplHomePage string + HomePageTemplate = tmpl.MustCompile(&HomePage{}) +) + +type HomePage struct { + HeadCommonPartial `tmpl:"head_common"` + TopPartial `tmpl:"top"` + FooterPartial `tmpl:"footer"` + + Host string + Npubs []string + LastNotes []string +} + +func (*HomePage) TemplateText() string { + return tmplHomePage +} + var ( //go:embed templates/archive.html tmplArchive string diff --git a/render_homepage.go b/render_homepage.go index e9137ba..62415ed 100644 --- a/render_homepage.go +++ b/render_homepage.go @@ -10,7 +10,6 @@ import ( ) func renderHomepage(w http.ResponseWriter, r *http.Request) { - typ := "homepage" w.Header().Set("Cache-Control", "max-age=3600") npubsHex := cache.GetPaginatedkeys("pa", 1, 50) @@ -36,13 +35,14 @@ func renderHomepage(w http.ResponseWriter, r *http.Request) { lastNotes = append(lastNotes, nevent) } - params := map[string]any{ - "npubs": npubs, - "lastNotes": lastNotes, - } + err := HomePageTemplate.Render(w, &HomePage{ + HeadCommonPartial: HeadCommonPartial{IsProfile: false}, - if err := tmpls.ExecuteTemplate(w, templateMapping[typ], params); err != nil { - log.Error().Err(err).Msg("error rendering") - return + Host: s.Domain, + Npubs: npubs, + LastNotes: lastNotes, + }) + if err != nil { + log.Error().Err(err).Msg("error rendering tmpl") } } diff --git a/templates/homepage.html b/templates/homepage.html index 16461ab..d3d4ded 100644 --- a/templates/homepage.html +++ b/templates/homepage.html @@ -26,16 +26,14 @@ (yet) working.
- njump currently lives under {{ s.Domain }}, you can
- reach it appending a Nostr
+ njump currently lives under {{ .Host }}, you can reach it
+ appending a Nostr
NIP-19
entity (npub, nevent, naddr,
etc) after the domain:
- {{ s.Domain }}/<nip-19-entity>.
+ {{ .Host }}/<nip-19-entity>.
For example, here's @@ -63,7 +61,7 @@