github.com/neohugo/neohugo@v0.123.8/hugolib/page__meta_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 ( 17 "strings" 18 "testing" 19 ) 20 21 // Issue 9793 22 // Issue 12115 23 func TestListTitles(t *testing.T) { 24 t.Parallel() 25 26 files := ` 27 -- hugo.toml -- 28 disableKinds = ['home','rss','sitemap'] 29 capitalizeListTitles = true 30 pluralizeListTitles = true 31 [taxonomies] 32 tag = 'tags' 33 -- content/section-1/page-1.md -- 34 --- 35 title: page-1 36 tags: 'tag-a' 37 --- 38 -- layouts/_default/list.html -- 39 {{ .Title }} 40 -- layouts/_default/single.html -- 41 {{ .Title }} 42 ` 43 44 b := Test(t, files) 45 46 b.AssertFileContent("public/section-1/index.html", "Section-1s") 47 b.AssertFileContent("public/tags/index.html", "Tags") 48 b.AssertFileContent("public/tags/tag-a/index.html", "Tag-A") 49 50 files = strings.Replace(files, "true", "false", -1) 51 52 b = Test(t, files) 53 54 b.AssertFileContent("public/section-1/index.html", "section-1") 55 b.AssertFileContent("public/tags/index.html", "tags") 56 b.AssertFileContent("public/tags/tag-a/index.html", "tag-a") 57 } 58 59 func TestDraftNonDefaultContentLanguage(t *testing.T) { 60 t.Parallel() 61 62 files := ` 63 -- hugo.toml -- 64 defaultContentLanguage = "en" 65 [languages] 66 [languages.en] 67 weight = 1 68 [languages.nn] 69 weight = 2 70 -- content/p1.md -- 71 -- content/p2.nn.md -- 72 --- 73 title: "p2" 74 draft: true 75 --- 76 -- layouts/_default/single.html -- 77 {{ .Title }} 78 ` 79 b := Test(t, files) 80 81 b.AssertFileExists("public/nn/p2/index.html", false) 82 }