diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-05 10:20:06 +0700 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-17 17:15:26 +0100 |
commit | 93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch) | |
tree | 5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /hugolib/pagination.go | |
parent | e34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff) |
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables
the use if `t.Parallel` in tests.
Updates #2701
Fixes #3016
Diffstat (limited to 'hugolib/pagination.go')
-rw-r--r-- | hugolib/pagination.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hugolib/pagination.go b/hugolib/pagination.go index acfa2b75e..aa20f8d55 100644 --- a/hugolib/pagination.go +++ b/hugolib/pagination.go @@ -21,6 +21,8 @@ import ( "path" "reflect" + "github.com/spf13/hugo/config" + "github.com/spf13/cast" "github.com/spf13/hugo/helpers" ) @@ -266,7 +268,7 @@ func (p *Page) Paginator(options ...interface{}) (*Pager, error) { if !p.IsNode() { return nil, fmt.Errorf("Paginators not supported for pages of type %q (%q)", p.Kind, p.Title) } - pagerSize, err := resolvePagerSize(options...) + pagerSize, err := resolvePagerSize(p.s.Cfg, options...) if err != nil { return nil, err @@ -310,7 +312,7 @@ func (p *Page) Paginate(seq interface{}, options ...interface{}) (*Pager, error) return nil, fmt.Errorf("Paginators not supported for pages of type %q (%q)", p.Kind, p.Title) } - pagerSize, err := resolvePagerSize(options...) + pagerSize, err := resolvePagerSize(p.s.Cfg, options...) if err != nil { return nil, err @@ -353,9 +355,9 @@ func (p *Page) Paginate(seq interface{}, options ...interface{}) (*Pager, error) return p.paginator, nil } -func resolvePagerSize(options ...interface{}) (int, error) { +func resolvePagerSize(cfg config.Provider, options ...interface{}) (int, error) { if len(options) == 0 { - return helpers.Config().GetInt("paginate"), nil + return cfg.GetInt("paginate"), nil } if len(options) > 1 { |