diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-08-11 19:26:45 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-09-06 18:32:20 +0300 |
commit | bbfebdea433f7b08dbd9d49c2df863c7a24b9665 (patch) | |
tree | af7e1808360fbdf1b246d5de5f7a47d818d3266d /hugolib | |
parent | 93717aac5cba7407e016ab993d7d277d9bad9956 (diff) |
Fix Data in multisites
Updates #2309
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/hugo_sites.go | 9 | ||||
-rw-r--r-- | hugolib/hugo_sites_test.go | 12 |
2 files changed, 13 insertions, 8 deletions
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index d05415d98..9aafb953a 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -373,9 +373,12 @@ func (h *HugoSites) setupTranslations(master *Site) { } } - for i := 1; i < len(h.Sites); i++ { - h.Sites[i].AllPages = h.Sites[0].AllPages - } + } + + // Pull over the collections from the master site + for i := 1; i < len(h.Sites); i++ { + h.Sites[i].AllPages = h.Sites[0].AllPages + h.Sites[i].Data = h.Sites[0].Data } if len(h.Sites) > 1 { diff --git a/hugolib/hugo_sites_test.go b/hugolib/hugo_sites_test.go index 50ee1ee72..152994020 100644 --- a/hugolib/hugo_sites_test.go +++ b/hugolib/hugo_sites_test.go @@ -254,6 +254,10 @@ func doTestMultiSitesBuild(t *testing.T, configContent, configSuffix string) { languageRedirect := readDestination(t, "public/index.html") require.True(t, strings.Contains(languageRedirect, "0; url=http://example.com/blog/fr"), languageRedirect) + // check home page content (including data files rendering) + assertFileContent(t, "public/en/index.html", true, "Home Page 1", "Hello", "Hugo Rocks!") + assertFileContent(t, "public/fr/index.html", true, "Home Page 1", "Bonjour", "Hugo Rocks!") + // Check node translations homeEn := enSite.getNode("home-0") require.NotNil(t, homeEn) @@ -729,7 +733,7 @@ func createMultiTestSitesForConfig(t *testing.T, configContent, configSuffix str if err := afero.WriteFile(hugofs.Source(), filepath.Join("layouts", "index.html"), - []byte("{{ $p := .Paginator }}Home Page {{ $p.PageNumber }}: {{ .Title }}|{{ .IsHome }}|{{ i18n \"hello\" }}|{{ .Permalink }}"), + []byte("{{ $p := .Paginator }}Home Page {{ $p.PageNumber }}: {{ .Title }}|{{ .IsHome }}|{{ i18n \"hello\" }}|{{ .Permalink }}|{{ .Site.Data.hugo.slogan }}"), 0755); err != nil { t.Fatalf("Failed to write layout file: %s", err) } @@ -885,11 +889,9 @@ lag: t.Fatalf("Failed to write file: %s", err) } } - _, err := hugofs.Source().Open("content/other/doc5.fr.md") - if err != nil { - t.Fatalf("Unable to locate file") - } + // Add some data + writeSource(t, "data/hugo.toml", "slogan = \"Hugo Rocks!\"") sites, err := NewHugoSitesFromConfiguration() |