chore: used feed name in list of feeds during render
5339a840
3 file(s) · +14 −3
| 31 | 31 | FormattedDate string |
|
| 32 | 32 | } |
|
| 33 | 33 | ||
| 34 | + | type feedRef struct { |
|
| 35 | + | Name string |
|
| 36 | + | URL string |
|
| 37 | + | } |
|
| 38 | + | ||
| 34 | 39 | type indexPageData struct { |
|
| 35 | 40 | BaseURL string |
|
| 36 | 41 | Items []templateItem |
|
| 37 | - | FeedURLs []string |
|
| 42 | + | FeedURLs []feedRef |
|
| 38 | 43 | Error string |
|
| 39 | 44 | MetaTitle string |
|
| 40 | 45 | MetaDescription string |
| 26 | 26 | render(a.Templates, w, "index.html", data, a.Log) |
|
| 27 | 27 | return |
|
| 28 | 28 | } |
|
| 29 | - | data.FeedURLs = urls |
|
| 30 | 29 | data.CanonicalURL = a.BaseURL + r.URL.RequestURI() |
|
| 31 | 30 | data.OGImage = a.BaseURL + "/og.png?" + r.URL.RawQuery |
|
| 32 | 31 | ||
| 38 | 37 | } |
|
| 39 | 38 | if len(data.Items) == 0 { |
|
| 40 | 39 | data.Error = "No items could be loaded from these feeds" |
|
| 40 | + | } |
|
| 41 | + | for _, u := range urls { |
|
| 42 | + | name := titles[u] |
|
| 43 | + | if name == "" { |
|
| 44 | + | name = hostName(u) |
|
| 45 | + | } |
|
| 46 | + | data.FeedURLs = append(data.FeedURLs, feedRef{Name: name, URL: u}) |
|
| 41 | 47 | } |
|
| 42 | 48 | data.MetaTitle, data.MetaDescription = feedMeta(urls, titles, len(data.Items)) |
|
| 43 | 49 | render(a.Templates, w, "index.html", data, a.Log) |
|
| 31 | 31 | ||
| 32 | 32 | {{if .FeedURLs}} |
|
| 33 | 33 | <div id="feed-urls"> |
|
| 34 | - | {{range .FeedURLs}}{{.}}<br>{{end}} |
|
| 34 | + | {{range .FeedURLs}}{{.Name}}<br>{{end}} |
|
| 35 | 35 | </div> |
|
| 36 | 36 | ||
| 37 | 37 | {{if .Error}} |