summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-28 17:28:44 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-02-28 19:26:55 +0100
commitbe1dbba0f78f2cf7f7019c01cc8705fa339ea995 (patch)
tree279db9e715424518c8a2d460a60315dfb1376610
parent1007bcdf49b983a5d7e1948d92a40b8728cb2ba0 (diff)
Fix draft for non-default content when content in default language does not exist
Fixes #12132
-rw-r--r--hugolib/content_map_page.go5
-rw-r--r--hugolib/page__meta_test.go33
2 files changed, 31 insertions, 7 deletions
diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go
index 1114428df..5388426c9 100644
--- a/hugolib/content_map_page.go
+++ b/hugolib/content_map_page.go
@@ -685,13 +685,13 @@ func (s *contentNodeShifter) Delete(n contentNodeI, dimension doctree.Dimension)
}
return wasDeleted, isEmpty
case *resourceSource:
- if lidx > 0 {
+ if lidx != v.LangIndex() {
return false, false
}
resource.MarkStale(v)
return true, true
case *pageState:
- if lidx > 0 {
+ if lidx != v.s.languagei {
return false, false
}
resource.MarkStale(v)
@@ -1714,6 +1714,7 @@ func (sa *sitePagesAssembler) removeShouldNotBuild() error {
if len(keys) == 0 {
return nil
}
+
sa.pageMap.DeletePageAndResourcesBelow(keys...)
return nil
diff --git a/hugolib/page__meta_test.go b/hugolib/page__meta_test.go
index d4b66ed9a..58d29464d 100644
--- a/hugolib/page__meta_test.go
+++ b/hugolib/page__meta_test.go
@@ -11,13 +11,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package hugolib_test
+package hugolib
import (
"strings"
"testing"
-
- "github.com/gohugoio/hugo/hugolib"
)
// Issue 9793
@@ -43,7 +41,7 @@ tags: 'tag-a'
{{ .Title }}
`
- b := hugolib.Test(t, files)
+ b := Test(t, files)
b.AssertFileContent("public/section-1/index.html", "Section-1s")
b.AssertFileContent("public/tags/index.html", "Tags")
@@ -51,9 +49,34 @@ tags: 'tag-a'
files = strings.Replace(files, "true", "false", -1)
- b = hugolib.Test(t, files)
+ b = Test(t, files)
b.AssertFileContent("public/section-1/index.html", "section-1")
b.AssertFileContent("public/tags/index.html", "tags")
b.AssertFileContent("public/tags/tag-a/index.html", "tag-a")
}
+
+func TestDraftNonDefaultContentLanguage(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+defaultContentLanguage = "en"
+[languages]
+[languages.en]
+weight = 1
+[languages.nn]
+weight = 2
+-- content/p1.md --
+-- content/p2.nn.md --
+---
+title: "p2"
+draft: true
+---
+-- layouts/_default/single.html --
+{{ .Title }}
+`
+ b := Test(t, files)
+
+ b.AssertFileExists("public/nn/p2/index.html", false)
+}