aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2016-09-15 09:32:52 +0200
committerBjørn Erik Pedersen <[email protected]>2016-09-15 09:32:52 +0200
commitb86a605bfb14450d56f4e7faeb4fc5fa8c936438 (patch)
tree5fc32bce53a880a706ef28b2041081995693894e /helpers
parentbbb11a4a0f9b4673ecba52d349e90db8c352e444 (diff)
downloadhugo-b86a605bfb14450d56f4e7faeb4fc5fa8c936438.tar.gz
hugo-b86a605bfb14450d56f4e7faeb4fc5fa8c936438.zip
Make paginate settings configurable per language
Fixes #2449
Diffstat (limited to 'helpers')
-rw-r--r--helpers/configProvider.go11
-rw-r--r--helpers/language.go4
-rw-r--r--helpers/path.go2
3 files changed, 14 insertions, 3 deletions
diff --git a/helpers/configProvider.go b/helpers/configProvider.go
index 16a203302..35500f6de 100644
--- a/helpers/configProvider.go
+++ b/helpers/configProvider.go
@@ -17,9 +17,20 @@
// string operations on content.
package helpers
+import (
+ "github.com/spf13/viper"
+)
+
// ConfigProvider provides the configuration settings for Hugo.
type ConfigProvider interface {
GetString(key string) string
+ GetInt(key string) int
GetStringMap(key string) map[string]interface{}
GetStringMapString(key string) map[string]string
}
+
+// Config returns the currently active Hugo config. This will be set
+// per site (language) rendered.
+func Config() ConfigProvider {
+ return viper.Get("CurrentContentLanguage").(ConfigProvider)
+}
diff --git a/helpers/language.go b/helpers/language.go
index c822dedd0..9ebec5a65 100644
--- a/helpers/language.go
+++ b/helpers/language.go
@@ -84,9 +84,9 @@ func (l *Language) SetParam(k string, v interface{}) {
l.params[k] = v
}
-func (l *Language) GetBool(key string) bool { return cast.ToBool(l.Get(key)) }
-
+func (l *Language) GetBool(key string) bool { return cast.ToBool(l.Get(key)) }
func (l *Language) GetString(key string) string { return cast.ToString(l.Get(key)) }
+func (l *Language) GetInt(key string) int { return cast.ToInt(l.Get(key)) }
func (ml *Language) GetStringMap(key string) map[string]interface{} {
return cast.ToStringMap(ml.Get(key))
diff --git a/helpers/path.go b/helpers/path.go
index b7e6f51a9..b8f642470 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -341,7 +341,7 @@ func GetRelativePath(path, base string) (final string, err error) {
// PaginateAliasPath creates a path used to access the aliases in the paginator.
func PaginateAliasPath(base string, page int) string {
- paginatePath := viper.GetString("paginatePath")
+ paginatePath := Config().GetString("paginatePath")
uglify := viper.GetBool("UglyURLs")
var p string
if base != "" {