hugolib: Simplify some code
authorCameron Moore <moorereason@gmail.com>
Tue, 28 Aug 2018 20:51:44 +0000 (15:51 -0500)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 30 Aug 2018 20:31:29 +0000 (22:31 +0200)
hugolib/page.go
hugolib/page_test.go
hugolib/pagemeta/page_frontmatter.go
hugolib/site_output.go

index 629b90484bee8a1f770f5401e6bc3be9405e4a0c..bb6dab8e04a14d070fc35976854ba1959bc40347 100644 (file)
@@ -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) {
index adf4294fc5a854aa44366a6cc877ef31fc1a2199..ee6e73a4d972d0757c4b681c266d94ed3112f52e 100644 (file)
@@ -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"
index 8bfc4e837e844769c6ae997c42d2232a88fbdd0c..c1139bd907cd592c9c2647b91ded7cad1ba51d67 100644 (file)
@@ -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)
                        }
                }
        }
index 497092e8ca4cc3f157ca1ef17535e77384448fc2..f81162e4306031b2f35bc4f5f04c48fbed58c0e9 100644 (file)
@@ -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
        }