You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
583 B
Go
32 lines
583 B
Go
2 years ago
|
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
|
||
|
}
|