hugolib: Remove "double layout" lookup
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 17 Dec 2018 09:47:11 +0000 (10:47 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 17 Dec 2018 10:34:32 +0000 (11:34 +0100)
Fixes #5390

go.sum
hugolib/hugo_sites.go
hugolib/site.go
hugolib/site_render.go

diff --git a/go.sum b/go.sum
index f7cfa6da96df6c27a37491d5000885ce4f1d9fb5..ea33a1abbff45ff4a119fbd858897004e8166b6f 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -72,6 +72,7 @@ github.com/magefile/mage v1.4.0 h1:RI7B1CgnPAuu2O9lWszwya61RLmfL0KCdo+QyyI/Bhk=
 github.com/magefile/mage v1.4.0/go.mod h1:IUDi13rsHje59lecXokTfGX0QIzO45uVPlXnJYsXepA=
 github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
 github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6 h1:LZhVjIISSbj8qLf2qDPP0D8z0uvOWAW5C85ly5mJW6c=
 github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6/go.mod h1:oTeZL2KHA7CUX6X+fovmK9OvIOFuqu0TwdQrZjLTh88=
 github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
 github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
index c1fa7979c3c5dd349d5f33117a2eb36bad5de742..a211956df2bb93df987c5a87bbbe45023ccf5b31 100644 (file)
@@ -486,7 +486,7 @@ func (h *HugoSites) renderCrossSitesArtifacts() error {
        smLayouts := []string{"sitemapindex.xml", "_default/sitemapindex.xml", "_internal/_default/sitemapindex.xml"}
 
        return s.renderAndWriteXML(&s.PathSpec.ProcessingStats.Sitemaps, "sitemapindex",
-               sitemapDefault.Filename, h.toSiteInfos(), s.appendThemeTemplates(smLayouts)...)
+               sitemapDefault.Filename, h.toSiteInfos(), smLayouts...)
 }
 
 func (h *HugoSites) assignMissingTranslations() error {
index cf8b3a28de92a241b717d82e5e82fcdf654a7983..2fd9f17eeb9f3633b4f293e3b84e353a52845bf3 100644 (file)
@@ -1648,36 +1648,6 @@ func (s *Site) errorCollator(results <-chan error, errs chan<- error) {
        close(errs)
 }
 
-func (s *Site) appendThemeTemplates(in []string) []string {
-       if !s.PathSpec.ThemeSet() {
-               return in
-       }
-
-       out := []string{}
-       // First place all non internal templates
-       for _, t := range in {
-               if !strings.HasPrefix(t, "_internal/") {
-                       out = append(out, t)
-               }
-       }
-
-       // Then place theme templates with the same names
-       for _, t := range in {
-               if !strings.HasPrefix(t, "_internal/") {
-                       out = append(out, "theme/"+t)
-               }
-       }
-
-       // Lastly place internal templates
-       for _, t := range in {
-               if strings.HasPrefix(t, "_internal/") {
-                       out = append(out, t)
-               }
-       }
-       return out
-
-}
-
 // GetPage looks up a page of a given type for the given ref.
 // In Hugo <= 0.44 you had to add Page Kind (section, home) etc. as the first
 // argument and then either a unix styled path (with or without a leading slash))
index a8cdca255e85b8f82ce4cab5f5895fd233417ac2..4ce2b4c53d1070e99471ccdc96f9f93fcc0fe088 100644 (file)
@@ -303,7 +303,7 @@ func (s *Site) render404() error {
                s.Log.ERROR.Printf("Failed to create target path for page %q: %s", p, err)
        }
 
-       return s.renderAndWritePage(&s.PathSpec.ProcessingStats.Pages, "404 page", targetPath, pageOutput, s.appendThemeTemplates(nfLayouts)...)
+       return s.renderAndWritePage(&s.PathSpec.ProcessingStats.Pages, "404 page", targetPath, pageOutput, nfLayouts...)
 }
 
 func (s *Site) renderSitemap() error {
@@ -354,7 +354,7 @@ func (s *Site) renderSitemap() error {
        addLanguagePrefix := n.Site.IsMultiLingual()
 
        return s.renderAndWriteXML(&s.PathSpec.ProcessingStats.Sitemaps, "sitemap",
-               n.addLangPathPrefixIfFlagSet(page.Sitemap.Filename, addLanguagePrefix), n, s.appendThemeTemplates(smLayouts)...)
+               n.addLangPathPrefixIfFlagSet(page.Sitemap.Filename, addLanguagePrefix), n, smLayouts...)
 }
 
 func (s *Site) renderRobotsTXT() error {
@@ -385,7 +385,7 @@ func (s *Site) renderRobotsTXT() error {
                s.Log.ERROR.Printf("Failed to create target path for page %q: %s", p, err)
        }
 
-       return s.renderAndWritePage(&s.PathSpec.ProcessingStats.Pages, "Robots Txt", targetPath, pageOutput, s.appendThemeTemplates(rLayouts)...)
+       return s.renderAndWritePage(&s.PathSpec.ProcessingStats.Pages, "Robots Txt", targetPath, pageOutput, rLayouts...)
 
 }