github.com/neohugo/neohugo@v0.123.8/hugolib/hugo_sites_test.go (about)

     1  // Copyright 2024 The Hugo Authors. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package hugolib
    15  
    16  import "testing"
    17  
    18  func TestSitesAndLanguageOrder(t *testing.T) {
    19  	files := `
    20  -- hugo.toml --
    21  defaultContentLanguage = "fr"
    22  defaultContentLanguageInSubdir = true
    23  [languages]
    24  [languages.en]
    25  weight = 1
    26  [languages.fr]
    27  weight = 2
    28  [languages.de]
    29  weight = 3
    30  -- layouts/index.html --
    31  {{ $bundle := site.GetPage "bundle" }}
    32  Bundle all translations: {{ range $bundle.AllTranslations }}{{ .Lang }}|{{ end }}$
    33  Bundle translations: {{ range $bundle.Translations }}{{ .Lang }}|{{ end }}$
    34  Site languages: {{ range site.Languages }}{{ .Lang }}|{{ end }}$
    35  Sites: {{ range site.Sites }}{{ .Language.Lang }}|{{ end }}$
    36  -- content/bundle/index.fr.md --
    37  ---
    38  title: "Bundle Fr"
    39  ---
    40  -- content/bundle/index.en.md --
    41  ---
    42  title: "Bundle En"
    43  ---
    44  -- content/bundle/index.de.md --
    45  ---
    46  title: "Bundle De"
    47  ---
    48  	
    49  	`
    50  	b := Test(t, files)
    51  
    52  	b.AssertFileContent("public/en/index.html",
    53  		"Bundle all translations: en|fr|de|$",
    54  		"Bundle translations: fr|de|$",
    55  		"Site languages: en|fr|de|$",
    56  		"Sites: fr|en|de|$",
    57  	)
    58  }