Instead of having entire articles in the RSS feed, items now contain just a link

This commit is contained in:
2024-08-30 21:20:29 +02:00
parent 4a11e1a497
commit 3f1b18c29f
18 changed files with 349 additions and 108 deletions

View File

@@ -39,7 +39,7 @@ func GetChannel(db *DB, title, link, description string) (*rss.Channel, error) {
channel.Items = append(channel.Items, &rss.Item{
Title: article.Title,
Author: user.FirstName + user.LastName,
Author: fmt.Sprint(user.FirstName, " ", user.LastName),
PubDate: article.Created.Format(time.RFC1123Z),
Description: article.Description,
Content: &rss.Content{Value: article.Content},
@@ -89,14 +89,22 @@ func GenerateRSS(c *Config, db *DB) (*string, error) {
return nil, fmt.Errorf("error converting description to plain text for RSS feed: %v", err)
}
channel.Items = append(channel.Items, &rss.Item{
Author: fmt.Sprint(user.FirstName, user.LastName),
item := &rss.Item{
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,
})
}
fmt.Println(article.Link, ": ", len(article.Link))
if article.Link == "" {
item.Link = fmt.Sprint("http://", c.Domain, "/article/serve/", article.ID, ".html")
} else {
item.Link = article.Link
}
channel.Items = append(channel.Items, item)
}
feed := rss.NewFeed()