github.com/neohugo/neohugo@v0.123.8/hugolib/language_content_dir_test.go (about) 1 // Copyright 2019 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 ( 17 "testing" 18 ) 19 20 func TestLanguageContentRoot(t *testing.T) { 21 files := ` 22 -- hugo.toml -- 23 baseURL = "https://example.org/" 24 defaultContentLanguage = "en" 25 defaultContentLanguageInSubdir = true 26 [languages] 27 [languages.en] 28 weight = 10 29 contentDir = "content/en" 30 [languages.nn] 31 weight = 20 32 contentDir = "content/nn" 33 -- content/en/_index.md -- 34 --- 35 title: "Home" 36 --- 37 -- content/nn/_index.md -- 38 --- 39 title: "Heim" 40 --- 41 -- content/en/myfiles/file1.txt -- 42 file 1 en 43 -- content/en/myfiles/file2.txt -- 44 file 2 en 45 -- content/nn/myfiles/file1.txt -- 46 file 1 nn 47 -- layouts/index.html -- 48 Title: {{ .Title }}| 49 Len Resources: {{ len .Resources }}| 50 {{ range $i, $e := .Resources }} 51 {{ $i }}|{{ .RelPermalink }}|{{ .Content }}| 52 {{ end }} 53 54 ` 55 b := Test(t, files) 56 b.AssertFileContent("public/en/index.html", "Home", "0|/en/myfiles/file1.txt|file 1 en|\n\n1|/en/myfiles/file2.txt|file 2 en|") 57 b.AssertFileContent("public/nn/index.html", "Heim", "0|/nn/myfiles/file1.txt|file 1 nn|\n\n1|/en/myfiles/file2.txt|file 2 en|") 58 }