Start refactor

This commit is contained in:
vxclutch
2026-05-25 09:21:24 -04:00
parent cbf9f0e695
commit bfb79d8d64
3 changed files with 62 additions and 14 deletions

View File

@@ -0,0 +1,49 @@
package articles
import (
"log"
"wire/internal/api"
)
type Articles []Article
type Article struct {
Title string
Link string
Description string
Content string
}
type ArticleParser struct {
url string
limit int
}
func NewParser(url string) *ArticleParser {
ap := ArticleParser{
url: url,
limit: 15,
}
return &ap
}
func (ap *ArticleParser) GetArticles() (as Articles) {
items, err := api.FetchRSS(ap.url)
if err != nil {
log.Fatal(err)
}
for i, v := range items {
if i == ap.limit {
break
}
as = append(as, Article{
Title: v.Title,
Link: v.Link,
Description: v.Description,
Content: v.Content,
})
}
return
}