1
0
dwelling-home/web/rss.templ

38 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

package web
import "net/http"
import "strings"
import "time"
import "git.arav.su/Arav/dwelling-home/pkg/mindflow"
import "git.arav.su/Arav/dwelling-home/pkg/util"
templ RSS(host, author string, posts []mindflow.Post, r *http.Request) {
@templ.Raw("<?xml version=\"1.0\" encoding=\"utf-8\" ?>")
<rss version="2.0">
<channel>
<title>Arav's dwelling</title>
<description>What's going on with me and my machines.</description>
<language>en-gb</language>
<link>{ host }</link>
for _, post := range posts {
<item>
<title>{ post.Title }</title>
<category>{ post.Category.Name }</category>
<guid>{ post.PostID() }</guid>
<pubDate>{ util.ToClientTimezone(post.Date, r).Format(time.RFC1123Z) }</pubDate>
<link>{ post.PostURL(r.Host, true) }</link>
<author>{ author }</author>
<description>
@templ.Raw("<![CDATA[")
for _, line := range strings.Split(post.Body, "\n") {
<p>{ line }</p>
}
@templ.Raw("]]>")
</description>
</item>
}
</channel>
</rss>
}