]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl: Resolve layouts/all.html for all html output formats
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 11 Apr 2025 08:54:19 +0000 (10:54 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 11 Apr 2025 16:23:51 +0000 (18:23 +0200)
Fixes #13587

tpl/templates/templates_integration_test.go
tpl/tplimpl/templatedescriptor.go

index 7527095931d4bf317acbd216197047261981aade..4150ec367db98e6e34aa5a37e7d4bced2a8d7119 100644 (file)
@@ -194,3 +194,23 @@ Home.
        b.AssertFileContent("public/index.html", "layouts/baseof.html")
        b.AssertFileContent("public/amp/index.html", "layouts/baseof.amp.html")
 }
+
+func TestAllVsAmp(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+-- content/_index.md --
+---
+title: "Home"
+outputs: ["html", "amp"]
+---
+title: "Home"
+-- layouts/all.html --
+All.
+
+`
+       b := hugolib.Test(t, files)
+       b.AssertFileContent("public/index.html", "All.")
+       b.AssertFileContent("public/amp/index.html", "All.")
+}
index 21649b0327b62a07484e9810ff29fbf87c41c99d..fc757126f866b135ba09c5e6e46984f624edbb88 100644 (file)
@@ -92,6 +92,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
        if other.Kind != "" && other.Kind != this.Kind {
                return w
        }
+
        if other.Layout != "" && other.Layout != layoutAll && other.Layout != this.Layout {
                if isLayoutCustom(this.Layout) {
                        if this.Kind == "" {
@@ -108,6 +109,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
                        return w
                }
        }
+
        if other.Lang != "" && other.Lang != this.Lang {
                return w
        }
@@ -120,7 +122,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
                // We want e.g. home page in amp output format (media type text/html) to
                // find a template even if one isn't specified for that output format,
                // when one exist for the html output format (same media type).
-               if category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && this.Layout != other.Layout)) {
+               if category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && (this.Layout != other.Layout && other.Layout != layoutAll))) {
                        return w
                }