mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
libsass: Resolve directory paths to directory index files
Closes #12851
This commit is contained in:
parent
2bc27657d8
commit
5b442b3cce
4 changed files with 56 additions and 5 deletions
|
@ -566,6 +566,9 @@ Styles: {{ $r.RelPermalink }}
|
||||||
// Issue 12849
|
// Issue 12849
|
||||||
func TestDirectoryIndexes(t *testing.T) {
|
func TestDirectoryIndexes(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
if !dartsass.Supports() {
|
||||||
|
t.Skip()
|
||||||
|
}
|
||||||
|
|
||||||
files := `
|
files := `
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
|
|
|
@ -166,9 +166,10 @@ func (t importResolver) CanonicalizeURL(url string) (string, error) {
|
||||||
namePatterns = []string{"_%s.scss", "_%s.sass", "_%s.css"}
|
namePatterns = []string{"_%s.scss", "_%s.sass", "_%s.css"}
|
||||||
} else {
|
} else {
|
||||||
namePatterns = []string{
|
namePatterns = []string{
|
||||||
"_%s.scss", "%s.scss", "%s/_index.scss",
|
"_%s.scss", "%s.scss",
|
||||||
"_%s.sass", "%s.sass", "%s/_index.sass",
|
"_%s.sass", "%s.sass",
|
||||||
"_%s.css", "%s.css",
|
"_%s.css", "%s.css",
|
||||||
|
"%s/_index.scss", "%s/_index.sass",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,3 +417,46 @@ h3 {
|
||||||
|
|
||||||
b.AssertFileContent("public/index.html", `b.46b2d77c7ffe37ee191678f72df991ecb1319f849957151654362f09b0ef467f.css`)
|
b.AssertFileContent("public/index.html", `b.46b2d77c7ffe37ee191678f72df991ecb1319f849957151654362f09b0ef467f.css`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 12851
|
||||||
|
func TestDirectoryIndexes(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
if !scss.Supports() {
|
||||||
|
t.Skip()
|
||||||
|
}
|
||||||
|
|
||||||
|
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" "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;}
|
||||||
|
`
|
||||||
|
|
||||||
|
b := hugolib.NewIntegrationTestBuilder(
|
||||||
|
hugolib.IntegrationTestConfig{
|
||||||
|
T: t,
|
||||||
|
NeedsOsFS: true,
|
||||||
|
TxtarString: files,
|
||||||
|
}).Build()
|
||||||
|
|
||||||
|
b.AssertFileContent("public/index.html", ".foo{color:red}.bar{color:green}")
|
||||||
|
}
|
||||||
|
|
|
@ -105,7 +105,11 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx
|
||||||
} else if strings.HasPrefix(name, "_") {
|
} else if strings.HasPrefix(name, "_") {
|
||||||
namePatterns = []string{"_%s.scss", "_%s.sass"}
|
namePatterns = []string{"_%s.scss", "_%s.sass"}
|
||||||
} else {
|
} else {
|
||||||
namePatterns = []string{"_%s.scss", "%s.scss", "_%s.sass", "%s.sass"}
|
namePatterns = []string{
|
||||||
|
"_%s.scss", "%s.scss",
|
||||||
|
"_%s.sass", "%s.sass",
|
||||||
|
"%s/_index.scss", "%s/_index.sass",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
name = strings.TrimPrefix(name, "_")
|
name = strings.TrimPrefix(name, "_")
|
||||||
|
|
Loading…
Reference in a new issue