Skip to content

Commit

Permalink
hugolib: Simplify some code
Browse files Browse the repository at this point in the history
  • Loading branch information
moorereason authored and bep committed Aug 30, 2018
1 parent 0665a39 commit e38e881
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
4 changes: 1 addition & 3 deletions hugolib/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1440,9 +1440,7 @@ func (p *Page) update(frontmatter map[string]interface{}) error {
resources = append(resources, cast.ToStringMap(vvv))
}
case []map[string]interface{}:
for _, vvv := range vv {
resources = append(resources, vvv)
}
resources = append(resources, vv...)
case []interface{}:
for _, vvv := range vv {
switch vvvv := vvv.(type) {
Expand Down
6 changes: 2 additions & 4 deletions hugolib/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,8 @@ func testAllMarkdownEnginesForPages(t *testing.T,

cfg, fs := newTestCfg()

if settings != nil {
for k, v := range settings {
cfg.Set(k, v)
}
for k, v := range settings {
cfg.Set(k, v)
}

contentDir := "content"
Expand Down
24 changes: 11 additions & 13 deletions hugolib/pagemeta/page_frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,17 @@ func newFrontmatterConfig(cfg config.Provider) (frontmatterConfig, error) {

if cfg.IsSet("frontmatter") {
fm := cfg.GetStringMap("frontmatter")
if fm != nil {
for k, v := range fm {
loki := strings.ToLower(k)
switch loki {
case fmDate:
c.date = toLowerSlice(v)
case fmPubDate:
c.publishDate = toLowerSlice(v)
case fmLastmod:
c.lastmod = toLowerSlice(v)
case fmExpiryDate:
c.expiryDate = toLowerSlice(v)
}
for k, v := range fm {
loki := strings.ToLower(k)
switch loki {
case fmDate:
c.date = toLowerSlice(v)
case fmPubDate:
c.publishDate = toLowerSlice(v)
case fmLastmod:
c.lastmod = toLowerSlice(v)
case fmExpiryDate:
c.expiryDate = toLowerSlice(v)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion hugolib/site_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func createSiteOutputFormats(allFormats output.Formats, cfg config.Provider) (ma

outputs := cfg.GetStringMap("outputs")

if outputs == nil || len(outputs) == 0 {
if len(outputs) == 0 {
return outFormats, nil
}

Expand Down

0 comments on commit e38e881

Please sign in to comment.