mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
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:
parent
540150da73
commit
ba25ddc855
14
blog/blog.go
14
blog/blog.go
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user