diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-01-30 11:43:20 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-01-30 20:12:19 +0100 |
commit | 5b7cb258ec26d7de690099f5dc39935b8d728155 (patch) | |
tree | 53544c8ab46e3fffda4a1e33c5d6e705183e2652 /hugolib/content_render_hooks_test.go | |
parent | 80595bbe3e7901ecd6200e59d43af142c3c85b6b (diff) |
Create default link and image render hooks
Fixes #11933
Diffstat (limited to 'hugolib/content_render_hooks_test.go')
-rw-r--r-- | hugolib/content_render_hooks_test.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go index 93b0e1621..36d1e626f 100644 --- a/hugolib/content_render_hooks_test.go +++ b/hugolib/content_render_hooks_test.go @@ -14,6 +14,7 @@ package hugolib import ( + "strings" "testing" ) @@ -169,3 +170,74 @@ Self Fragments: [d e f] P1 Fragments: [b c z] `) } + +func TestDefaultRenderHooksMultilingual(t *testing.T) { + files := ` +-- hugo.toml -- +baseURL = "https://example.org" +disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"] +defaultContentLanguage = "nn" +defaultContentLanguageInSubdir = true +[markup] +[markup.goldmark] +duplicateResourceFiles = false +[markup.goldmark.renderhooks] +[markup.goldmark.renderhooks.link] +#enableDefault = false +[markup.goldmark.renderhooks.image] +#enableDefault = false +[languages] +[languages.en] +weight = 1 +[languages.nn] +weight = 2 +-- content/p1/index.md -- +--- +title: "p1" +--- +[P2](p2) +![Pixel](pixel.png) +-- content/p2/index.md -- +--- +title: "p2" +--- +[P1](p1) +![Pixel](pixel.jpg) +-- content/p1/index.en.md -- +--- +title: "p1 en" +--- +[P2](p2) +![Pixel](pixel.png) +-- content/p2/index.en.md -- +--- +title: "p2 en" +--- +[P1](p1) +![Pixel](pixel.png) + +-- content/p1/pixel.nn.png -- +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg== +-- content/p2/pixel.png -- +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg== +-- layouts/_default/single.html -- +{{ .Title }}|{{ .Content }}|$ + +` + + t.Run("Default multilingual", func(t *testing.T) { + b := Test(t, files) + + b.AssertFileContent("public/nn/p1/index.html", + "p1|<p><a href=\"/nn/p2/\">P2</a\n></p>", "<img alt=\"Pixel\" src=\"/nn/p1/pixel.nn.png\">") + b.AssertFileContent("public/en/p1/index.html", + "p1 en|<p><a href=\"/en/p2/\">P2</a\n></p>", "<img alt=\"Pixel\" src=\"/nn/p1/pixel.nn.png\">") + }) + + t.Run("Disabled", func(t *testing.T) { + b := Test(t, strings.ReplaceAll(files, "#enableDefault = false", "enableDefault = false")) + + b.AssertFileContent("public/nn/p1/index.html", + "p1|<p><a href=\"p2\">P2</a>", "<img src=\"pixel.png\" alt=\"Pixel\">") + }) +} |