add tagline support

This commit is contained in:
Ryan Stafford 2023-12-16 22:10:31 -05:00
parent 797d40f9c1
commit d918604d75
2 changed files with 8 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"math/rand"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"net/url" "net/url"
@ -95,6 +96,7 @@ type State struct {
XHR bool XHR bool
Op string Op string
Site *lemmy.GetSiteResponse Site *lemmy.GetSiteResponse
Tagline string
Query string Query string
Content string Content string
SearchType string SearchType string
@ -279,6 +281,9 @@ func (state *State) GetSite() {
return return
} }
state.Site = resp state.Site = resp
if len(state.Site.Taglines) > 0 {
state.Tagline = state.Site.Taglines[rand.Intn(len(state.Site.Taglines))].Content
}
if !state.Site.MyUser.IsValid() { if !state.Site.MyUser.IsValid() {
return return
} }

View file

@ -15,6 +15,9 @@
{{ template "nsfw.html" }} {{ template "nsfw.html" }}
{{ else }} {{ else }}
<main> <main>
{{ if and (not .Community) .Tagline }}
<h3>{{ markdown .Host .Tagline }}</h3>
{{ end }}
{{ template "menu.html" . }} {{ template "menu.html" . }}
{{ if .Error }} {{ if .Error }}