Skip to content

Commit

Permalink
看起来一些阅读器没有显示更新后的内容(不确定修复)
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Jun 17, 2024
1 parent d17a641 commit 2082e50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 16 additions & 6 deletions theme/modules/rss/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ var tmpl string
// Article ...
type Article struct {
*proto.Post
Date string
Date Date
Content template.HTML
}

type Date int

func (d Date) String() string {
return time.Unix(int64(d), 0).Local().Format(time.RFC1123)
}

// RSS ...
type RSS struct {
config _Config
Expand All @@ -36,6 +42,8 @@ type RSS struct {
Home string
Articles []*Article

LastBuildDate Date

tmpl *template.Template
svc proto.TaoBlogServer
}
Expand All @@ -61,10 +69,12 @@ func New(svc proto.TaoBlogServer, options ...Option) *RSS {
articleCount: 10,
},

Name: info.Name,
Description: info.Description,
Home: info.Home,
svc: svc,
Name: info.Name,
Description: info.Description,
Home: info.Home,
LastBuildDate: Date(info.LastPostedAt),

svc: svc,
}

for _, opt := range options {
Expand Down Expand Up @@ -93,7 +103,7 @@ func (r *RSS) ServeHTTP(w http.ResponseWriter, req *http.Request) {
for _, article := range rsp.Posts {
rssArticle := Article{
Post: article,
Date: time.Unix(int64(article.Date), 0).Local().Format(time.RFC1123),
Date: Date(article.Date),
Content: template.HTML(cdata(article.Content)),
}
rssArticles = append(rssArticles, &rssArticle)
Expand Down
1 change: 1 addition & 0 deletions theme/modules/rss/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<title>{{ .Name }}</title>
<link>{{ .Home }}</link>
<description>{{ .Description }}</description>
<lastBuildDate>{{ .LastBuildDate }}</lastBuildDate>
{{- range .Articles }}
<item>
<title>{{ .Title }}</title>
Expand Down

0 comments on commit 2082e50

Please sign in to comment.