Some godoc adjustments and image struct renames

This commit is contained in:
Bjørn Erik Pedersen
2022-04-21 10:59:13 +02:00
parent 11047534e4
commit fa80fe3c8a
23 changed files with 193 additions and 90 deletions

View File

@@ -22,9 +22,11 @@ import (
"github.com/gohugoio/hugo/resources/resource"
)
// Pages is a slice of pages. This is the most common list type in Hugo.
// Pages is a slice of Page objects. This is the most common list type in Hugo.
type Pages []Page
// String returns a string representation of the list.
// For internal use.
func (ps Pages) String() string {
return fmt.Sprintf("Pages(%d)", len(ps))
}
@@ -37,7 +39,8 @@ func (ps Pages) shuffle() {
}
}
// ToResources wraps resource.ResourcesConverter
// ToResources wraps resource.ResourcesConverter.
// For internal use.
func (pages Pages) ToResources() resource.Resources {
r := make(resource.Resources, len(pages))
for i, p := range pages {
@@ -86,10 +89,12 @@ func ToPages(seq any) (Pages, error) {
return nil, fmt.Errorf("cannot convert type %T to Pages", seq)
}
// Group groups the pages in in by key.
// This implements collections.Grouper.
func (p Pages) Group(key any, in any) (any, error) {
pages, err := ToPages(in)
if err != nil {
return nil, err
return PageGroup{}, err
}
return PageGroup{Key: key, Pages: pages}, nil
}
@@ -100,6 +105,7 @@ func (p Pages) Len() int {
}
// ProbablyEq wraps compare.ProbablyEqer
// For internal use.
func (pages Pages) ProbablyEq(other any) bool {
otherPages, ok := other.(Pages)
if !ok {