summaryrefslogtreecommitdiffstats
path: root/hugolib/site.go
diff options
context:
space:
mode:
authorCameron Moore <moorereason@gmail.com>2018-10-02 20:54:36 -0500
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-03 09:34:45 +0300
commit1fd30d462ee7f67fde6f29d170af1d225258322b (patch)
treee73de2357390d7556e0d023a7ac399ff69bf79ca /hugolib/site.go
parent498d6299581bead0f582431b8133d8b5f8760618 (diff)
hugolib: Cast taxonomy weight parameters to int
Fixes #4628
Diffstat (limited to 'hugolib/site.go')
-rw-r--r--hugolib/site.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/hugolib/site.go b/hugolib/site.go
index 054656f7a..f7f84b47d 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1469,14 +1469,17 @@ func (s *Site) assembleTaxonomies() {
for _, p := range s.Pages {
vals := p.getParam(plural, !s.Info.preserveTaxonomyNames)
- weight := p.getParamToLower(plural + "_weight")
- if weight == nil {
- weight = 0
+
+ weight, err := cast.ToIntE(p.getParamToLower(plural + "_weight"))
+ if err != nil {
+ s.Log.ERROR.Print("unable to convert taxonomy weight to int")
+ // weight will equal zero, so let the flow continue
}
+
if vals != nil {
if v, ok := vals.([]string); ok {
for _, idx := range v {
- x := WeightedPage{weight.(int), p}
+ x := WeightedPage{weight, p}
s.Taxonomies[plural].add(s.getTaxonomyKey(idx), x)
if s.Info.preserveTaxonomyNames {
// Need to track the original
@@ -1484,7 +1487,7 @@ func (s *Site) assembleTaxonomies() {
}
}
} else if v, ok := vals.(string); ok {
- x := WeightedPage{weight.(int), p}
+ x := WeightedPage{weight, p}
s.Taxonomies[plural].add(s.getTaxonomyKey(v), x)
if s.Info.preserveTaxonomyNames {
// Need to track the original