mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	hugolib: Improve nil handling in IsDescendant and IsAncestor
Fixes #5461
This commit is contained in:
		| @@ -104,8 +104,11 @@ func (p *Page) InSection(other interface{}) (bool, error) { | ||||
| // IsDescendant returns whether the current page is a descendant of the given page. | ||||
| // Note that this method is not relevant for taxonomy lists and taxonomy terms pages. | ||||
| func (p *Page) IsDescendant(other interface{}) (bool, error) { | ||||
| 	if p == nil { | ||||
| 		return false, nil | ||||
| 	} | ||||
| 	pp, err := unwrapPage(other) | ||||
| 	if err != nil { | ||||
| 	if err != nil || pp == nil { | ||||
| 		return false, err | ||||
| 	} | ||||
|  | ||||
| @@ -119,8 +122,12 @@ func (p *Page) IsDescendant(other interface{}) (bool, error) { | ||||
| // IsAncestor returns whether the current page is an ancestor of the given page. | ||||
| // Note that this method is not relevant for taxonomy lists and taxonomy terms pages. | ||||
| func (p *Page) IsAncestor(other interface{}) (bool, error) { | ||||
| 	if p == nil { | ||||
| 		return false, nil | ||||
| 	} | ||||
|  | ||||
| 	pp, err := unwrapPage(other) | ||||
| 	if err != nil { | ||||
| 	if err != nil || pp == nil { | ||||
| 		return false, err | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user