mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Fix permalink functionality, which was broken in 62dd1d4
.
Viper stores Permalinks as a map[string]interface{}, so the type assertion to PermalinkOverrides (map[string]PathPattern) will always fail. We can, however, get Permalinks as a map[string]string, and convert each value to a PathPattern.
This commit is contained in:
parent
05b76dcb6f
commit
025a37df2f
2 changed files with 15 additions and 3 deletions
|
@ -265,9 +265,9 @@ func (s *Site) initializeSiteInfo() {
|
||||||
params = make(map[string]interface{})
|
params = make(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
permalinks, ok := viper.Get("Permalinks").(PermalinkOverrides)
|
permalinks := make(PermalinkOverrides)
|
||||||
if !ok {
|
for k, v := range viper.GetStringMapString("Permalinks") {
|
||||||
permalinks = make(PermalinkOverrides)
|
permalinks[k] = PathPattern(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Info = SiteInfo{
|
s.Info = SiteInfo{
|
||||||
|
|
|
@ -30,3 +30,15 @@ func TestSiteInfoParams(t *testing.T) {
|
||||||
t.Errorf("Expected FOOBAR_PARAM: got %s", buf.String())
|
t.Errorf("Expected FOOBAR_PARAM: got %s", buf.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSiteInfoPermalinks (t *testing.T) {
|
||||||
|
viper.Set("Permalinks", map[string]interface{}{"section": "/:title"})
|
||||||
|
s := &Site{}
|
||||||
|
|
||||||
|
s.initialize()
|
||||||
|
permalink := s.Info.Permalinks["section"]
|
||||||
|
|
||||||
|
if permalink != "/:title" {
|
||||||
|
t.Errorf("Could not set permalink (%#v)", permalink)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue