-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Page method/field to taxonomy object #12316
Comments
This is what type Taxonomy map[string]WeightedPages
What we in theory could do, but that would not work for empty taxonomies: func (t Taxonomy) Page() page.Page {
var first WeightedPages
range _, v := t {
first = v
break
}
if first == nil {
return nil
}
return first.Page().Parent()
} |
I tested with this: // Page returns the taxonomy page or nil if the taxonomy has no terms.
func (i Taxonomy) Page() Page {
var first WeightedPages
for _, v := range i {
first = v
break
}
if first == nil {
return nil
}
return first.Page().Parent()
} and this:
Works great. I think this is OK as long as we document the "returns nil if no term pages" part. And it's kind of sneaky, so I like it. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
We can get a reference to a term page with:
It would be convenient if we could get a reference to a taxonomy page with:
That may not be possible, despite the fact we lowercase terms internally (e.g., there shouldn't be a collision between
tags.page
(a term) andtags.Page
(a method/field).The alternative has always seemed less elegant compared to how you can get a reference to a term page:
The text was updated successfully, but these errors were encountered: