|
14 | 14 | package hugolib
|
15 | 15 |
|
16 | 16 | import (
|
| 17 | + "strings" |
17 | 18 | "testing"
|
18 | 19 | )
|
19 | 20 |
|
@@ -169,3 +170,74 @@ Self Fragments: [d e f]
|
169 | 170 | P1 Fragments: [b c z]
|
170 | 171 | `)
|
171 | 172 | }
|
| 173 | + |
| 174 | +func TestDefaultRenderHooksMultilingual(t *testing.T) { |
| 175 | + files := ` |
| 176 | +-- hugo.toml -- |
| 177 | +baseURL = "https://example.org" |
| 178 | +disableKinds = ["taxonomy", "term", "RSS", "sitemap", "robotsTXT"] |
| 179 | +defaultContentLanguage = "nn" |
| 180 | +defaultContentLanguageInSubdir = true |
| 181 | +[markup] |
| 182 | +[markup.goldmark] |
| 183 | +duplicateResourceFiles = false |
| 184 | +[markup.goldmark.renderhooks] |
| 185 | +[markup.goldmark.renderhooks.link] |
| 186 | +#enableDefault = false |
| 187 | +[markup.goldmark.renderhooks.image] |
| 188 | +#enableDefault = false |
| 189 | +[languages] |
| 190 | +[languages.en] |
| 191 | +weight = 1 |
| 192 | +[languages.nn] |
| 193 | +weight = 2 |
| 194 | +-- content/p1/index.md -- |
| 195 | +--- |
| 196 | +title: "p1" |
| 197 | +--- |
| 198 | +[P2](p2) |
| 199 | + |
| 200 | +-- content/p2/index.md -- |
| 201 | +--- |
| 202 | +title: "p2" |
| 203 | +--- |
| 204 | +[P1](p1) |
| 205 | + |
| 206 | +-- content/p1/index.en.md -- |
| 207 | +--- |
| 208 | +title: "p1 en" |
| 209 | +--- |
| 210 | +[P2](p2) |
| 211 | + |
| 212 | +-- content/p2/index.en.md -- |
| 213 | +--- |
| 214 | +title: "p2 en" |
| 215 | +--- |
| 216 | +[P1](p1) |
| 217 | + |
| 218 | +
|
| 219 | +-- content/p1/pixel.nn.png -- |
| 220 | +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg== |
| 221 | +-- content/p2/pixel.png -- |
| 222 | +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg== |
| 223 | +-- layouts/_default/single.html -- |
| 224 | +{{ .Title }}|{{ .Content }}|$ |
| 225 | + |
| 226 | +` |
| 227 | + |
| 228 | + t.Run("Default multilingual", func(t *testing.T) { |
| 229 | + b := Test(t, files) |
| 230 | + |
| 231 | + b.AssertFileContent("public/nn/p1/index.html", |
| 232 | + "p1|<p><a href=\"/nn/p2/\">P2</a\n></p>", "<img alt=\"Pixel\" src=\"/nn/p1/pixel.nn.png\">") |
| 233 | + b.AssertFileContent("public/en/p1/index.html", |
| 234 | + "p1 en|<p><a href=\"/en/p2/\">P2</a\n></p>", "<img alt=\"Pixel\" src=\"/nn/p1/pixel.nn.png\">") |
| 235 | + }) |
| 236 | + |
| 237 | + t.Run("Disabled", func(t *testing.T) { |
| 238 | + b := Test(t, strings.ReplaceAll(files, "#enableDefault = false", "enableDefault = false")) |
| 239 | + |
| 240 | + b.AssertFileContent("public/nn/p1/index.html", |
| 241 | + "p1|<p><a href=\"p2\">P2</a>", "<img src=\"pixel.png\" alt=\"Pixel\">") |
| 242 | + }) |
| 243 | +} |
0 commit comments