mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 22:50:35 +03:00
parent
48eec2a4e6
commit
621194a319
7 changed files with 14 additions and 13 deletions
|
@ -1087,7 +1087,7 @@ func (s *staticSyncer) syncsStaticEvents(staticEvents []fsnotify.Event) error {
|
||||||
|
|
||||||
fromPath := ev.Name
|
fromPath := ev.Name
|
||||||
|
|
||||||
relPath, found := sourceFs.MakePathRelative(fromPath)
|
relPath, found := sourceFs.MakePathRelative(fromPath, true)
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
// Not member of this virtual host.
|
// Not member of this virtual host.
|
||||||
|
|
|
@ -336,7 +336,7 @@ func (s *SourceFilesystems) ResolvePaths(filename string, checkExists bool) []hu
|
||||||
// It will return an empty string if the filename is not a member of a static filesystem.
|
// It will return an empty string if the filename is not a member of a static filesystem.
|
||||||
func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
|
func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
|
||||||
for _, staticFs := range s.Static {
|
for _, staticFs := range s.Static {
|
||||||
rel, _ := staticFs.MakePathRelative(filename)
|
rel, _ := staticFs.MakePathRelative(filename, true)
|
||||||
if rel != "" {
|
if rel != "" {
|
||||||
return rel
|
return rel
|
||||||
}
|
}
|
||||||
|
@ -345,8 +345,8 @@ func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakePathRelative creates a relative path from the given filename.
|
// MakePathRelative creates a relative path from the given filename.
|
||||||
func (d *SourceFilesystem) MakePathRelative(filename string) (string, bool) {
|
func (d *SourceFilesystem) MakePathRelative(filename string, checkExists bool) (string, bool) {
|
||||||
cps, err := d.ReverseLookup(filename)
|
cps, err := d.ReverseLookup(filename, checkExists)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -358,11 +358,11 @@ func (d *SourceFilesystem) MakePathRelative(filename string) (string, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReverseLookup returns the component paths for the given filename.
|
// ReverseLookup returns the component paths for the given filename.
|
||||||
func (d *SourceFilesystem) ReverseLookup(filename string) ([]hugofs.ComponentPath, error) {
|
func (d *SourceFilesystem) ReverseLookup(filename string, checkExists bool) ([]hugofs.ComponentPath, error) {
|
||||||
var cps []hugofs.ComponentPath
|
var cps []hugofs.ComponentPath
|
||||||
hugofs.WalkFilesystems(d.Fs, func(fs afero.Fs) bool {
|
hugofs.WalkFilesystems(d.Fs, func(fs afero.Fs) bool {
|
||||||
if rfs, ok := fs.(hugofs.ReverseLookupProvder); ok {
|
if rfs, ok := fs.(hugofs.ReverseLookupProvder); ok {
|
||||||
if c, err := rfs.ReverseLookup(filename, true); err == nil {
|
if c, err := rfs.ReverseLookup(filename, checkExists); err == nil {
|
||||||
cps = append(cps, c...)
|
cps = append(cps, c...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,11 +380,11 @@ Main.
|
||||||
`
|
`
|
||||||
b := hugolib.Test(t, files)
|
b := hugolib.Test(t, files)
|
||||||
|
|
||||||
rel, found := b.H.BaseFs.Assets.MakePathRelative(filepath.FromSlash("/themes/t1/src/main.js"))
|
rel, found := b.H.BaseFs.Assets.MakePathRelative(filepath.FromSlash("/themes/t1/src/main.js"), true)
|
||||||
b.Assert(found, qt.Equals, true)
|
b.Assert(found, qt.Equals, true)
|
||||||
b.Assert(rel, qt.Equals, filepath.FromSlash("foo/bar/main.js"))
|
b.Assert(rel, qt.Equals, filepath.FromSlash("foo/bar/main.js"))
|
||||||
|
|
||||||
rel, found = b.H.BaseFs.Assets.MakePathRelative(filepath.FromSlash("/bar.txt"))
|
rel, found = b.H.BaseFs.Assets.MakePathRelative(filepath.FromSlash("/bar.txt"), true)
|
||||||
b.Assert(found, qt.Equals, true)
|
b.Assert(found, qt.Equals, true)
|
||||||
b.Assert(rel, qt.Equals, filepath.FromSlash("foo/baz.txt"))
|
b.Assert(rel, qt.Equals, filepath.FromSlash("foo/baz.txt"))
|
||||||
}
|
}
|
||||||
|
@ -460,7 +460,7 @@ Home.
|
||||||
b.AssertFileContent("public/index.html", "Home.")
|
b.AssertFileContent("public/index.html", "Home.")
|
||||||
|
|
||||||
stat := func(path string) hugofs.FileMetaInfo {
|
stat := func(path string) hugofs.FileMetaInfo {
|
||||||
ps, err := b.H.BaseFs.Content.ReverseLookup(filepath.FromSlash(path))
|
ps, err := b.H.BaseFs.Content.ReverseLookup(filepath.FromSlash(path), true)
|
||||||
b.Assert(err, qt.IsNil)
|
b.Assert(err, qt.IsNil)
|
||||||
b.Assert(ps, qt.HasLen, 1)
|
b.Assert(ps, qt.HasLen, 1)
|
||||||
first := ps[0]
|
first := ps[0]
|
||||||
|
|
|
@ -243,7 +243,7 @@ func (c *pageFinder) getContentNodeFromRefReverseLookup(ref string, fi hugofs.Fi
|
||||||
|
|
||||||
realFilename := filepath.Join(dir, ref)
|
realFilename := filepath.Join(dir, ref)
|
||||||
|
|
||||||
pcs, err := s.BaseFs.Content.ReverseLookup(realFilename)
|
pcs, err := s.BaseFs.Content.ReverseLookup(realFilename, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ func createBuildPlugins(depsManager identity.Manager, c *Client, opts Options) (
|
||||||
isStdin := args.Importer == stdinImporter
|
isStdin := args.Importer == stdinImporter
|
||||||
var relDir string
|
var relDir string
|
||||||
if !isStdin {
|
if !isStdin {
|
||||||
rel, found := fs.MakePathRelative(args.Importer)
|
rel, found := fs.MakePathRelative(args.Importer, true)
|
||||||
if !found {
|
if !found {
|
||||||
// Not in any of the /assets folders.
|
// Not in any of the /assets folders.
|
||||||
// This is an import from a node_modules, let
|
// This is an import from a node_modules, let
|
||||||
|
|
|
@ -138,12 +138,13 @@ func (t importResolver) CanonicalizeURL(url string) (string, error) {
|
||||||
if url == sass.HugoVarsNamespace {
|
if url == sass.HugoVarsNamespace {
|
||||||
return url, nil
|
return url, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath, isURL := paths.UrlToFilename(url)
|
filePath, isURL := paths.UrlToFilename(url)
|
||||||
var prevDir string
|
var prevDir string
|
||||||
var pathDir string
|
var pathDir string
|
||||||
if isURL {
|
if isURL {
|
||||||
var found bool
|
var found bool
|
||||||
prevDir, found = t.c.sfs.MakePathRelative(filepath.Dir(filePath))
|
prevDir, found = t.c.sfs.MakePathRelative(filepath.Dir(filePath), false)
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
// Not a member of this filesystem, let Dart Sass handle it.
|
// Not a member of this filesystem, let Dart Sass handle it.
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (t *toCSSTransformation) Transform(ctx *resources.ResourceTransformationCtx
|
||||||
if prev == "stdin" {
|
if prev == "stdin" {
|
||||||
prevDir = baseDir
|
prevDir = baseDir
|
||||||
} else {
|
} else {
|
||||||
prevDir, _ = t.c.sfs.MakePathRelative(filepath.Dir(prev))
|
prevDir, _ = t.c.sfs.MakePathRelative(filepath.Dir(prev), false)
|
||||||
|
|
||||||
if prevDir == "" {
|
if prevDir == "" {
|
||||||
// Not a member of this filesystem. Let LibSASS handle it.
|
// Not a member of this filesystem. Let LibSASS handle it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue