node to page: Fix site pages sort
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 21 Nov 2016 09:35:57 +0000 (10:35 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 22 Nov 2016 08:57:03 +0000 (09:57 +0100)
Updates #2297

hugolib/hugo_sites.go

index 0da7efb8862ca8e3d32bc4c917a502164aa51582..843bfe82ff76963dc7d64adb01ed833190c6925c 100644 (file)
@@ -295,12 +295,23 @@ func (h *HugoSites) createMissingPages() error {
        }
 
        if len(newPages) > 0 {
+               // This resorting is unfortunate, but it also needs to be sorted
+               // when sections are created.
                first := h.Sites[0]
+
                first.AllPages = append(first.AllPages, newPages...)
+
+               first.AllPages.Sort()
+
+               for _, s := range h.Sites {
+                       s.Pages.Sort()
+               }
+
                for i := 1; i < len(h.Sites); i++ {
                        h.Sites[i].AllPages = first.AllPages
                }
        }
+
        return nil
 }