aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-12-10 13:33:27 +0100
committerGitHub <[email protected]>2024-12-10 13:33:27 +0100
commit5ab38de36387062a8ca6c1d18c6a773fa248519c (patch)
tree42181bdef2036525f562d3339e62921f36370fb5
parent7b69218489afe77ac15faa773ec968ad599a0214 (diff)
downloadhugo-5ab38de36387062a8ca6c1d18c6a773fa248519c.tar.gz
hugo-5ab38de36387062a8ca6c1d18c6a773fa248519c.zip
Fix Sass imports on the form index.{scss,sass}
Fixes #13123
-rw-r--r--resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go26
-rw-r--r--resources/resource_transformers/tocss/dartsass/transform.go1
-rw-r--r--resources/resource_transformers/tocss/scss/scss_integration_test.go26
-rw-r--r--resources/resource_transformers/tocss/scss/tocss.go1
4 files changed, 30 insertions, 24 deletions
diff --git a/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go b/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
index 5d1b89eaf..293fdfbcf 100644
--- a/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
+++ b/resources/resource_transformers/tocss/dartsass/dartsass_integration_test.go
@@ -577,23 +577,25 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']
[[module.mounts]]
source = 'assets'
target = 'assets'
-
-[[module.imports]]
-path = "github.com/gohugoio/hugoTestModule2"
-
-[[module.imports.mounts]]
+[[module.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;}
+@use "foo1"; // directory with _index file from OS file system
+@use "bar1"; // directory with _index file from module mount
+@use "foo2"; // directory with index file from OS file system
+@use "bar2"; // directory with index file from module mount
+-- assets/sass/foo1/_index.scss --
+.foo1 {color: red;}
+-- miscellaneous/sass/bar1/_index.scss --
+.bar1 {color: blue;}
+-- assets/sass/foo2/index.scss --
+.foo2 {color: red;}
+-- miscellaneous/sass/bar2/index.scss --
+.bar2 {color: blue;}
`
b := hugolib.NewIntegrationTestBuilder(
@@ -603,7 +605,7 @@ module hugo-github-issue-12849
TxtarString: files,
}).Build()
- b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
+ b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
}
func TestIgnoreDeprecationWarnings(t *testing.T) {
diff --git a/resources/resource_transformers/tocss/dartsass/transform.go b/resources/resource_transformers/tocss/dartsass/transform.go
index c5f97abff..0d7b57062 100644
--- a/resources/resource_transformers/tocss/dartsass/transform.go
+++ b/resources/resource_transformers/tocss/dartsass/transform.go
@@ -170,6 +170,7 @@ func (t importResolver) CanonicalizeURL(url string) (string, error) {
"_%s.sass", "%s.sass",
"_%s.css", "%s.css",
"%s/_index.scss", "%s/_index.sass",
+ "%s/index.scss", "%s/index.sass",
}
}
diff --git a/resources/resource_transformers/tocss/scss/scss_integration_test.go b/resources/resource_transformers/tocss/scss/scss_integration_test.go
index 10309ad20..0154a4634 100644
--- a/resources/resource_transformers/tocss/scss/scss_integration_test.go
+++ b/resources/resource_transformers/tocss/scss/scss_integration_test.go
@@ -432,23 +432,25 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term']
[[module.mounts]]
source = 'assets'
target = 'assets'
-
-[[module.imports]]
-path = "github.com/gohugoio/hugoTestModule2"
-
-[[module.imports.mounts]]
+[[module.mounts]]
source = "miscellaneous/sass"
target = "assets/sass"
--- go.mod --
-module hugo-github-issue-12849
-- layouts/index.html --
{{ $opts := dict "transpiler" "libsass" "outputStyle" "compressed" }}
{{ (resources.Get "sass/main.scss" | toCSS $opts).Content }}
-- assets/sass/main.scss --
-@import "foo"; // directory with index file from OS file system
-@import "bar"; // directory with index file from module mount
--- assets/sass/foo/_index.scss --
-.foo {color: red;}
+@import "foo1"; // directory with _index file from OS file system
+@import "bar1"; // directory with _index file from module mount
+@import "foo2"; // directory with index file from OS file system
+@import "bar2"; // directory with index file from module mount
+-- assets/sass/foo1/_index.scss --
+.foo1 {color: red;}
+-- miscellaneous/sass/bar1/_index.scss --
+.bar1 {color: blue;}
+-- assets/sass/foo2/index.scss --
+.foo2 {color: red;}
+-- miscellaneous/sass/bar2/index.scss --
+.bar2 {color: blue;}
`
b := hugolib.NewIntegrationTestBuilder(
@@ -458,5 +460,5 @@ module hugo-github-issue-12849
TxtarString: files,
}).Build()
- b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
+ b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
}
diff --git a/resources/resource_transformers/tocss/scss/tocss.go b/resources/resource_transformers/tocss/scss/tocss.go
index 4b9c51ce0..89e95b2f8 100644
--- a/resources/resource_transformers/tocss/scss/tocss.go
+++ b/resources/resource_transformers/tocss/scss/tocss.go
@@ -109,6 +109,7 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx
"_%s.scss", "%s.scss",
"_%s.sass", "%s.sass",
"%s/_index.scss", "%s/_index.sass",
+ "%s/index.scss", "%s/index.sass",
}
}