feat: automatic redirect if single configured feed

This commit is contained in:
Evan Buss
2024-08-10 21:36:52 +00:00
parent e21a648506
commit 6c41117af1

View File

@@ -132,6 +132,12 @@ func (s *Server) Serve() error {
func handleHome(feeds []FeedConfig) http.HandlerFunc { func handleHome(feeds []FeedConfig) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
// Don't make user click the only feed
if len(feeds) == 1 {
http.Redirect(w, r, "/feed?q="+feeds[0].Url, http.StatusFound)
return
}
vmFeeds := make([]html.FeedInfo, len(feeds)) vmFeeds := make([]html.FeedInfo, len(feeds))
for i, feed := range feeds { for i, feed := range feeds {
vmFeeds[i] = html.FeedInfo{ vmFeeds[i] = html.FeedInfo{