add self atom:link

This commit is contained in:
Niko Abeler 2023-07-21 21:59:25 +02:00
parent d736679418
commit ea06b26c9f
1 changed files with 17 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import (
type RSS struct { type RSS struct {
XMLName xml.Name `xml:"rss"` XMLName xml.Name `xml:"rss"`
Version string `xml:"version,attr"` Version string `xml:"version,attr"`
Atom string `xml:"xmlns:atom,attr"`
Channel RSSChannel `xml:"channel"` Channel RSSChannel `xml:"channel"`
} }
@ -24,9 +25,17 @@ type RSSDescription struct {
Text string `xml:",cdata"` Text string `xml:",cdata"`
} }
type AtomLink struct {
Href string `xml:"href,attr"`
Rel string `xml:"rel,attr,omitempty"`
Type string `xml:"type,attr,omitempty"`
Title string `xml:"title,attr,omitempty"`
}
type RSSChannel struct { type RSSChannel struct {
Title string `xml:"title"` Title string `xml:"title"`
Link string `xml:"link"` Link string `xml:"link"`
AtomLinks []AtomLink `xml:"atom:link"`
Description RSSDescription `xml:"description"` Description RSSDescription `xml:"description"`
Items []RSSItem `xml:"item"` Items []RSSItem `xml:"item"`
} }
@ -43,9 +52,17 @@ func RenderRSSFeed(config model.SiteConfig, entries []model.Entry) (string, erro
rss := RSS{ rss := RSS{
Version: "2.0", Version: "2.0",
Atom: "http://www.w3.org/2005/Atom",
Channel: RSSChannel{ Channel: RSSChannel{
Title: config.Title, Title: config.Title,
Link: config.FullUrl, Link: config.FullUrl,
AtomLinks: []AtomLink{
{
Href: config.FullUrl + "/index.xml",
Rel: "self",
Type: "application/rss+xml",
},
},
Description: RSSDescription{ Description: RSSDescription{
Text: config.SubTitle, Text: config.SubTitle,
}, },