mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
hugolib: Fix IsTranslated for "old" node types
The new logic for creating Page objects from old node types didn't include itself in the translation logic, so `IsTranslated` returned falsely false for sites with only two languages. The `AllTranslations` method also returned too few pages in that case. This commit fixes that. Fixes #2812
This commit is contained in:
@@ -1626,7 +1626,8 @@ func (p *Page) Lang() string {
|
||||
}
|
||||
|
||||
func (p *Page) isNewTranslation(candidate *Page) bool {
|
||||
if p == candidate || p.Kind != candidate.Kind {
|
||||
|
||||
if p.Kind != candidate.Kind {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1634,10 +1635,6 @@ func (p *Page) isNewTranslation(candidate *Page) bool {
|
||||
panic("Node type not currently supported for this op")
|
||||
}
|
||||
|
||||
if p.language.Lang == candidate.language.Lang {
|
||||
return false
|
||||
}
|
||||
|
||||
// At this point, we know that this is a traditional Node (home page, section, taxonomy)
|
||||
// It represents the same node, but different language, if the sections is the same.
|
||||
if len(p.sections) != len(candidate.sections) {
|
||||
@@ -1651,8 +1648,8 @@ func (p *Page) isNewTranslation(candidate *Page) bool {
|
||||
}
|
||||
|
||||
// Finally check that it is not already added.
|
||||
for _, translation := range candidate.translations {
|
||||
if p == translation {
|
||||
for _, translation := range p.translations {
|
||||
if candidate == translation {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user