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
}
}
} 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