Only provide link in item instead of the entire article via content

This commit is contained in:
2024-08-30 15:17:14 +02:00
parent 10d8fceb77
commit be467521d9
4 changed files with 45 additions and 16 deletions

View File

@ -50,11 +50,11 @@ func GetChannel(db *DB, title, link, description string) (*rss.Channel, error) {
return channel, nil
}
func GenerateRSS(db *DB, title, link, desc string) (*string, error) {
func GenerateRSS(c *Config, db *DB) (*string, error) {
channel := &rss.Channel{
Title: title,
Link: link,
Description: desc,
Title: c.Title,
Link: c.Link,
Description: c.Description,
Items: make([]*rss.Item, 0),
}
@ -89,18 +89,13 @@ func GenerateRSS(db *DB, title, link, desc string) (*string, error) {
return nil, fmt.Errorf("error converting description to plain text for RSS feed: %v", err)
}
articleContent, err := ConvertToHTML(article.Content)
if err != nil {
return nil, fmt.Errorf("error converting content to HTML for RSS feed: %v", err)
}
channel.Items = append(channel.Items, &rss.Item{
Title: articleTitle,
Author: user.FirstName + " " + user.LastName,
PubDate: article.Created.Format(time.RFC1123Z),
Description: articleDescription,
Content: &rss.Content{Value: articleContent},
Author: fmt.Sprint(user.FirstName, user.LastName),
Categories: tagNames,
Description: articleDescription,
Link: fmt.Sprintf("http://%s/article/serve/%d", c.Domain, article.ID),
PubDate: article.Created.Format(time.RFC1123Z),
Title: articleTitle,
})
}