mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-03 22:12:35 +00:00
allow space home update and its children pages (#101)
* allow space home update and its children pages * fix coding styling * fix coding styling * codestyle: fix checking isHomepage * codestyle: fix checking skipHomeAncestry Co-authored-by: Hugo Cisneiros (Eitch) <hugo.cisneiros@ifood.com.br> Co-authored-by: Egor Kovetskiy <e.kovetskiy@gmail.com>
This commit is contained in:
@@ -104,11 +104,26 @@ func ValidateAncestry(
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
isHomepage := false
|
||||
if len(page.Ancestors) < 1 {
|
||||
return nil, fmt.Errorf(`page %q has no parents`, page.Title)
|
||||
homepage, err := api.FindHomePage(space)
|
||||
if err != nil {
|
||||
return nil, karma.Format(
|
||||
err,
|
||||
"can't obtain home page from space %q",
|
||||
space,
|
||||
)
|
||||
}
|
||||
|
||||
if page.ID == homepage.ID {
|
||||
log.Debugf(nil, "page is homepage for space %q", space)
|
||||
isHomepage = true
|
||||
} else {
|
||||
return nil, fmt.Errorf(`page %q has no parents`, page.Title)
|
||||
}
|
||||
}
|
||||
|
||||
if len(page.Ancestors) < len(ancestry) {
|
||||
if !isHomepage && len(page.Ancestors) < len(ancestry) {
|
||||
actual := []string{}
|
||||
for _, ancestor := range page.Ancestors {
|
||||
actual = append(actual, ancestor.Title)
|
||||
|
||||
@@ -32,8 +32,25 @@ func ResolvePage(
|
||||
return nil, page, nil
|
||||
}
|
||||
|
||||
// check to see if home page is in Parents
|
||||
homepage, err := api.FindHomePage(meta.Space)
|
||||
if err != nil {
|
||||
return nil, nil, karma.Format(
|
||||
err,
|
||||
"can't obtain home page from space %q",
|
||||
meta.Space,
|
||||
)
|
||||
}
|
||||
|
||||
skipHomeAncestry := false
|
||||
if len(meta.Parents) > 0 {
|
||||
if homepage.Title == meta.Parents[0] {
|
||||
skipHomeAncestry = true
|
||||
}
|
||||
}
|
||||
|
||||
ancestry := meta.Parents
|
||||
if page != nil {
|
||||
if page != nil && !skipHomeAncestry {
|
||||
ancestry = append(ancestry, page.Title)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user