mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Fix multihost processed image not copied to non-default content languages
Fixes #12163
This commit is contained in:
parent
218690328c
commit
6bc0d745a5
2 changed files with 56 additions and 1 deletions
|
@ -162,6 +162,52 @@ title: "Mybundle fr"
|
||||||
b.AssertFileContent("public/fr/section/mybundle/styles.min.css", ".body{color:french}")
|
b.AssertFileContent("public/fr/section/mybundle/styles.min.css", ".body{color:french}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResourcePerLanguageIssue12163(t *testing.T) {
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
defaultContentLanguage = 'de'
|
||||||
|
disableKinds = ['rss','sitemap','taxonomy','term']
|
||||||
|
|
||||||
|
[languages.de]
|
||||||
|
baseURL = 'https://de.example.org/'
|
||||||
|
contentDir = 'content/de'
|
||||||
|
weight = 1
|
||||||
|
|
||||||
|
[languages.en]
|
||||||
|
baseURL = 'https://en.example.org/'
|
||||||
|
contentDir = 'content/en'
|
||||||
|
weight = 2
|
||||||
|
-- content/de/mybundle/index.md --
|
||||||
|
---
|
||||||
|
title: mybundle-de
|
||||||
|
---
|
||||||
|
-- content/de/mybundle/pixel.png --
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==
|
||||||
|
-- content/en/mybundle/index.md --
|
||||||
|
---
|
||||||
|
title: mybundle-en
|
||||||
|
---
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
{{ with .Resources.Get "pixel.png" }}
|
||||||
|
{{ with .Resize "2x2" }}
|
||||||
|
{{ .RelPermalink }}|
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
`
|
||||||
|
|
||||||
|
b := Test(t, files)
|
||||||
|
|
||||||
|
b.AssertFileExists("public/de/mybundle/index.html", true)
|
||||||
|
b.AssertFileExists("public/en/mybundle/index.html", true)
|
||||||
|
|
||||||
|
b.AssertFileExists("public/de/mybundle/pixel.png", true)
|
||||||
|
b.AssertFileExists("public/en/mybundle/pixel.png", true)
|
||||||
|
|
||||||
|
b.AssertFileExists("public/de/mybundle/pixel_hu8aa3346827e49d756ff4e630147c42b5_70_2x2_resize_box_3.png", true)
|
||||||
|
// failing test below
|
||||||
|
b.AssertFileExists("public/en/mybundle/pixel_hu8aa3346827e49d756ff4e630147c42b5_70_2x2_resize_box_3.png", true)
|
||||||
|
}
|
||||||
|
|
||||||
func TestMultihostResourceOneBaseURLWithSuPath(t *testing.T) {
|
func TestMultihostResourceOneBaseURLWithSuPath(t *testing.T) {
|
||||||
files := `
|
files := `
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
|
|
|
@ -39,7 +39,16 @@ func (c *ImageCache) getOrCreate(
|
||||||
) (*resourceAdapter, error) {
|
) (*resourceAdapter, error) {
|
||||||
relTarget := parent.relTargetPathFromConfig(conf)
|
relTarget := parent.relTargetPathFromConfig(conf)
|
||||||
relTargetPath := relTarget.TargetPath()
|
relTargetPath := relTarget.TargetPath()
|
||||||
memKey := dynacache.CleanKey(relTargetPath)
|
memKey := relTargetPath
|
||||||
|
|
||||||
|
// For multihost sites, we duplicate language versions of the same resource,
|
||||||
|
// so we need to include the language in the key.
|
||||||
|
// Note that we don't need to include the language in the file cache key,
|
||||||
|
// as the hash will take care of any different content.
|
||||||
|
if c.pathSpec.Cfg.IsMultihost() {
|
||||||
|
memKey = c.pathSpec.Lang() + memKey
|
||||||
|
}
|
||||||
|
memKey = dynacache.CleanKey(memKey)
|
||||||
|
|
||||||
v, err := c.mcache.GetOrCreate(memKey, func(key string) (*resourceAdapter, error) {
|
v, err := c.mcache.GetOrCreate(memKey, func(key string) (*resourceAdapter, error) {
|
||||||
var img *imageResource
|
var img *imageResource
|
||||||
|
|
Loading…
Reference in a new issue