feat: RSS feeds for {news,guide}
parent
9c10e1b8fc
commit
c1a701353a
@ -0,0 +1,31 @@
|
||||
package rss
|
||||
|
||||
import (
|
||||
"git.phc.dm.unipi.it/phc/website/articles"
|
||||
"github.com/gorilla/feeds"
|
||||
)
|
||||
|
||||
func GenerateRssFeed(entries []*articles.Article) *feeds.Feed {
|
||||
|
||||
// Initialize RSS Feed
|
||||
feed := &feeds.Feed{}
|
||||
|
||||
var feedItems []*feeds.Item
|
||||
|
||||
// Add items to RSS feeds
|
||||
for _, entry := range entries {
|
||||
|
||||
feedItems = append(feedItems,
|
||||
&feeds.Item{
|
||||
Id: entry.Id,
|
||||
Title: entry.Title,
|
||||
Link: &feeds.Link{Href: entry.ArticlePath},
|
||||
Description: entry.Description,
|
||||
Created: entry.PublishDate,
|
||||
})
|
||||
}
|
||||
|
||||
feed.Items = feedItems
|
||||
|
||||
return feed
|
||||
}
|
Loading…
Reference in New Issue