Allow specifying sort order and tags through config
This commit is contained in:
parent
3aa1f273b6
commit
720549ec7e
2 changed files with 22 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ package feed
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -54,7 +55,22 @@ func getLobstersPostsFromFeed(feedUrl string) (ForumPosts, error) {
|
|||
return posts, nil
|
||||
}
|
||||
|
||||
func FetchLobstersTopPosts(feedUrl string) (ForumPosts, error) {
|
||||
func FetchLobstersPosts(sortBy string, tags []string) (ForumPosts, error) {
|
||||
var feedUrl string
|
||||
|
||||
if sortBy == "hot" {
|
||||
sortBy = "hottest"
|
||||
} else if sortBy == "new" {
|
||||
sortBy = "newest"
|
||||
}
|
||||
|
||||
if len(tags) == 0 {
|
||||
feedUrl = "https://lobste.rs/" + sortBy + ".json"
|
||||
} else {
|
||||
tags := strings.Join(tags, ",")
|
||||
feedUrl = "https://lobste.rs/t/" + tags + ".json"
|
||||
}
|
||||
|
||||
posts, err := getLobstersPostsFromFeed(feedUrl)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue