Skip to content

Commit

Permalink
fix: W3C验证失败
Browse files Browse the repository at this point in the history
- [ ] Invalid email address
    在实现rss功能时用户表里还没有邮箱,所以在Author字段中只填了Name没填Email。现在邮箱已在邮件通知分支中添加,不过为了避免重复混淆,Rss分支上暂不处理。
- [x] Feeds should not be served with the "text/plain" media type
    只在前端链接中指定了`type="application/rss+xml"`,但后端接口没有正确设定Header中的Content-Type,已修正。
- [x] item should contain a guid element
    字段缺失,已修正
- [ ] Missing atom:link with rel="self"
    `gorilla\feeds`库的问题,见[gorilla/feeds kingwrcy#111](gorilla/feeds#111)
  • Loading branch information
Jinvic committed Feb 11, 2025
1 parent 0366bcb commit f00f73a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/handler/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (r RssHandler) GetRss(c echo.Context) error {
if err != nil {
return FailRespWithMsg(c, Fail, "RSS生成失败")
}

c.Response().Header().Set(echo.HeaderContentType, "application/rss+xml; charset=utf-8")

return c.String(http.StatusOK, rss)
}

Expand Down Expand Up @@ -102,9 +105,11 @@ func generateFeed(memos []db.Memo, sysConfigVO *vo.FullSysConfigVO, user *db.Use

feed.Items = []*feeds.Item{}
for _, memo := range memos {
memoLink := fmt.Sprintf("%s/memo/%d", host, memo.Id)
feed.Items = append(feed.Items, &feeds.Item{
Id: memoLink,
Title: fmt.Sprintf("Memo #%d", memo.Id),
Link: &feeds.Link{Href: fmt.Sprintf("%s/memo/%d", host, memo.Id)},
Link: &feeds.Link{Href: memoLink},
Description: parseMarkdownToHtml(getContentWithExt(memo, host)),
Author: &feeds.Author{Name: memo.User.Nickname},
Created: *memo.CreatedAt,
Expand Down

0 comments on commit f00f73a

Please sign in to comment.