]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
dartsass: Resolve directory paths to directory index files
authorJoe Mooring <joe.mooring@veriphor.com>
Fri, 13 Sep 2024 22:54:23 +0000 (15:54 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 15 Sep 2024 18:32:11 +0000 (20:32 +0200)
Closes #12849

resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
resources/resource_transformers/tocss/dartsass/transform.go

index 4d48b3b6a6bb08c1ceaf77a8cc08aec337e29b87..7b2b03dc0a9c64474fe75934792953b7c801c60b 100644 (file)
@@ -562,3 +562,43 @@ Styles: {{ $r.RelPermalink }}
 
        b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
 }
+
+// Issue 12849
+func TestDirectoryIndexes(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+disableKinds = ['page','section','rss','sitemap','taxonomy','term']
+
+[[module.mounts]]
+source = 'assets'
+target = 'assets'
+
+[[module.imports]]
+path = "github.com/gohugoio/hugoTestModule2"
+
+[[module.imports.mounts]]
+source = "miscellaneous/sass"
+target = "assets/sass"
+-- go.mod --
+module hugo-github-issue-12849
+-- layouts/index.html --
+{{ $opts := dict "transpiler" "dartsass" "outputStyle" "compressed" }}
+{{ (resources.Get "sass/main.scss" | toCSS $opts).Content }}
+-- assets/sass/main.scss --
+@use "foo"; // directory with index file from OS file system
+@use "bar"; // directory with index file from module mount
+-- assets/sass/foo/_index.scss --
+.foo {color: red;}
+`
+
+       b := hugolib.NewIntegrationTestBuilder(
+               hugolib.IntegrationTestConfig{
+                       T:           t,
+                       NeedsOsFS:   true,
+                       TxtarString: files,
+               }).Build()
+
+       b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
+}
index 99a5c3f683ec164bc8beddaeb9b0d56ed721ae83..ddf28723beabbf9710cc24a1998432960f6accf8 100644 (file)
@@ -165,7 +165,11 @@ func (t importResolver) CanonicalizeURL(url string) (string, error) {
        } else if strings.HasPrefix(name, "_") {
                namePatterns = []string{"_%s.scss", "_%s.sass", "_%s.css"}
        } else {
-               namePatterns = []string{"_%s.scss", "%s.scss", "_%s.sass", "%s.sass", "_%s.css", "%s.css"}
+               namePatterns = []string{
+                       "_%s.scss", "%s.scss", "%s/_index.scss",
+                       "_%s.sass", "%s.sass", "%s/_index.sass",
+                       "_%s.css", "%s.css",
+               }
        }
 
        name = strings.TrimPrefix(name, "_")