aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/resource_transformers
diff options
context:
space:
mode:
authorJoe Mooring <[email protected]>2024-09-13 15:54:23 -0700
committerBjørn Erik Pedersen <[email protected]>2024-09-15 20:32:11 +0200
commit2bc27657d8b75eabdeaf4df8b354efed8e079169 (patch)
treef02007c8afb037b0434a943986a7a5ce146634e4 /resources/resource_transformers
parent28f621d4a73ca7e97e23b33cbf3780ddab188d24 (diff)
downloadhugo-2bc27657d8b75eabdeaf4df8b354efed8e079169.tar.gz
hugo-2bc27657d8b75eabdeaf4df8b354efed8e079169.zip
dartsass: Resolve directory paths to directory index files
Closes #12849
Diffstat (limited to 'resources/resource_transformers')
-rw-r--r--resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go40
-rw-r--r--resources/resource_transformers/tocss/dartsass/transform.go6
2 files changed, 45 insertions, 1 deletions
diff --git a/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go b/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
index 4d48b3b6a..7b2b03dc0 100644
--- a/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
+++ b/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
@@ -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}")
+}
diff --git a/resources/resource_transformers/tocss/dartsass/transform.go b/resources/resource_transformers/tocss/dartsass/transform.go
index 99a5c3f68..ddf28723b 100644
--- a/resources/resource_transformers/tocss/dartsass/transform.go
+++ b/resources/resource_transformers/tocss/dartsass/transform.go
@@ -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, "_")