Don’t make publication date a link when it would be to same link as title. Fix #412.

This commit is contained in:
Brent Simmons 2018-09-03 12:50:24 -07:00
parent 8373ef06eb
commit 8d37275edb
1 changed files with 11 additions and 1 deletions

View File

@ -198,7 +198,7 @@ class ArticleRenderer {
let longDate = longDateFormatter.string(from: article.logicalDatePublished) let longDate = longDateFormatter.string(from: article.logicalDatePublished)
let mediumDate = mediumDateFormatter.string(from: article.logicalDatePublished) let mediumDate = mediumDateFormatter.string(from: article.logicalDatePublished)
let shortDate = shortDateFormatter.string(from: article.logicalDatePublished) let shortDate = shortDateFormatter.string(from: article.logicalDatePublished)
if let permalink = article.url { if dateShouldBeLink() || self.title == "", let permalink = article.url {
d["date_long"] = linkWithText(longDate, permalink) d["date_long"] = linkWithText(longDate, permalink)
d["date_medium"] = linkWithText(mediumDate, permalink) d["date_medium"] = linkWithText(mediumDate, permalink)
d["date_short"] = linkWithText(shortDate, permalink) d["date_short"] = linkWithText(shortDate, permalink)
@ -215,6 +215,16 @@ class ArticleRenderer {
return d return d
} }
private func dateShouldBeLink() -> Bool {
guard let permalink = article.url else {
return false
}
guard let preferredLink = article.preferredLink else { // Title uses preferredLink
return false
}
return permalink != preferredLink // Make date a link if its a different link from the titles link
}
struct Avatar { struct Avatar {
let imageURL: String let imageURL: String
let url: String? let url: String?