blog: use first OldURL to generate atom feed ID

This way, renaming an article does not make it reappear
in an RSS reader as a new article.

Change-Id: I4e92707f9ea4983bf8506cde826d5e5f48a3b36f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/223751
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Russ Cox 2020-03-17 17:03:11 -04:00
Родитель 540150da73
Коммит ba25ddc855
1 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -312,9 +312,21 @@ func (s *Server) renderAtomFeed() error {
if i >= s.cfg.FeedArticles {
break
}
// Use original article path as ID in atom feed
// to avoid articles being treated as new when renamed.
idPath := doc.Path
if len(doc.OldURL) > 0 {
old := doc.OldURL[0]
if !strings.HasPrefix(old, "/") {
old = "/" + old
}
idPath = old
}
e := &atom.Entry{
Title: doc.Title,
ID: feed.ID + doc.Path,
ID: feed.ID + idPath,
Link: []atom.Link{{
Rel: "alternate",
Href: doc.Permalink,