Fix language handling in shortcode templates

Fixes #13767
This commit is contained in:
Bjørn Erik Pedersen
2025-05-31 10:06:13 +02:00
parent 6334948515
commit 5273a884d4
3 changed files with 70 additions and 17 deletions

View File

@@ -757,3 +757,40 @@ title: home
b.AssertFileContent("public/index.html", "de.html")
}
func TestShortcodeLanguage13767(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
defaultContentLanguage = 'pl'
defaultContentLanguageInSubdir = true
[languages.pl]
weight = 1
[languages.en]
weight = 2
-- content/_index.md --
---
title: dom
---
{{< myshortcode >}}
-- content/_index.en.md --
---
title: home
---
{{< myshortcode >}}
-- layouts/_shortcodes/myshortcode.html --
myshortcode.html
-- layouts/_shortcodes/myshortcode.en.html --
myshortcode.en.html
-- layouts/all.html --
{{ .Content }}
`
b := hugolib.Test(t, files)
b.AssertFileContent("public/pl/index.html", "myshortcode.html")
b.AssertFileContent("public/en/index.html", "myshortcode.en.html")
}