Skip to content

Commit

Permalink
Add multilingual multihost support
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Nov 11, 2017
1 parent 9299a16 commit da58a91
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hugolib/hugo_sites_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ lag:
t.Fatalf("Failed to create sites: %s", err)
}

if len(sites.Sites) != 4 {
if len(sites.Sites) == 0 {
t.Fatalf("Got %d sites", len(sites.Sites))
}

Expand Down
62 changes: 62 additions & 0 deletions hugolib/hugo_sites_multihost_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package hugolib

import (
"testing"

"github.com/spf13/afero"
"github.com/stretchr/testify/require"
)

func TestMultihosts(t *testing.T) {
t.Parallel()

var multiSiteTOMLConfigTemplate = `
paginate = 1
disablePathToLower = true
defaultContentLanguage = "{{ .DefaultContentLanguage }}"
[permalinks]
other = "/somewhere/else/:filename"
[Taxonomies]
tag = "tags"
[Languages]
[Languages.en]
baseURL = "https://example.com"
weight = 10
title = "In English"
languageName = "English"
[Languages.fr]
baseURL = "https://example.fr"
weight = 20
title = "Le Français"
languageName = "Français"
[Languages.nn]
baseURL = "https://example.no"
weight = 30
title = "På nynorsk"
languageName = "Nynorsk"
`

siteConfig := testSiteConfig{Fs: afero.NewMemMapFs(), DefaultContentLanguage: "fr", DefaultContentLanguageInSubdir: true}
sites := createMultiTestSites(t, siteConfig, multiSiteTOMLConfigTemplate)
fs := sites.Fs
cfg := BuildCfg{Watching: true}
th := testHelper{sites.Cfg, fs, t}
assert := require.New(t)

err := sites.Build(cfg)
assert.NoError(err)

th.assertFileContent("public/en/sect/doc1-slug/index.html", "Hello")
enSite := sites.Sites[0]
enSiteHome := enSite.getPage(KindHome)
assert.True(enSiteHome.IsTranslated())
assert.Len(enSiteHome.Translations(), 2)
assert.Equal("https://example.com/", enSiteHome.Permalink())

}

0 comments on commit da58a91

Please sign in to comment.