mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
dartsass: Resolve directory paths to directory index files
Closes #12849
This commit is contained in:
parent
28f621d4a7
commit
2bc27657d8
2 changed files with 45 additions and 1 deletions
|
@ -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}")
|
||||
}
|
||||
|
|
|
@ -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, "_")
|
||||
|
|
Loading…
Reference in a new issue