mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Fix draft for non-default content when content in default language does not exist
Fixes #12132
This commit is contained in:
parent
1007bcdf49
commit
be1dbba0f7
2 changed files with 31 additions and 7 deletions
|
@ -685,13 +685,13 @@ func (s *contentNodeShifter) Delete(n contentNodeI, dimension doctree.Dimension)
|
||||||
}
|
}
|
||||||
return wasDeleted, isEmpty
|
return wasDeleted, isEmpty
|
||||||
case *resourceSource:
|
case *resourceSource:
|
||||||
if lidx > 0 {
|
if lidx != v.LangIndex() {
|
||||||
return false, false
|
return false, false
|
||||||
}
|
}
|
||||||
resource.MarkStale(v)
|
resource.MarkStale(v)
|
||||||
return true, true
|
return true, true
|
||||||
case *pageState:
|
case *pageState:
|
||||||
if lidx > 0 {
|
if lidx != v.s.languagei {
|
||||||
return false, false
|
return false, false
|
||||||
}
|
}
|
||||||
resource.MarkStale(v)
|
resource.MarkStale(v)
|
||||||
|
@ -1714,6 +1714,7 @@ func (sa *sitePagesAssembler) removeShouldNotBuild() error {
|
||||||
if len(keys) == 0 {
|
if len(keys) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sa.pageMap.DeletePageAndResourcesBelow(keys...)
|
sa.pageMap.DeletePageAndResourcesBelow(keys...)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -11,13 +11,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package hugolib_test
|
package hugolib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/hugolib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Issue 9793
|
// Issue 9793
|
||||||
|
@ -43,7 +41,7 @@ tags: 'tag-a'
|
||||||
{{ .Title }}
|
{{ .Title }}
|
||||||
`
|
`
|
||||||
|
|
||||||
b := hugolib.Test(t, files)
|
b := Test(t, files)
|
||||||
|
|
||||||
b.AssertFileContent("public/section-1/index.html", "Section-1s")
|
b.AssertFileContent("public/section-1/index.html", "Section-1s")
|
||||||
b.AssertFileContent("public/tags/index.html", "Tags")
|
b.AssertFileContent("public/tags/index.html", "Tags")
|
||||||
|
@ -51,9 +49,34 @@ tags: 'tag-a'
|
||||||
|
|
||||||
files = strings.Replace(files, "true", "false", -1)
|
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/section-1/index.html", "section-1")
|
||||||
b.AssertFileContent("public/tags/index.html", "tags")
|
b.AssertFileContent("public/tags/index.html", "tags")
|
||||||
b.AssertFileContent("public/tags/tag-a/index.html", "tag-a")
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue