mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
ba35e69856
commit
096f5e1921
2 changed files with 21 additions and 5 deletions
|
@ -30,6 +30,8 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gohugoio/hugo/hugofs/files"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/types"
|
"github.com/gohugoio/hugo/common/types"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/hugofs"
|
"github.com/gohugoio/hugo/hugofs"
|
||||||
|
@ -1200,12 +1202,16 @@ func partitionDynamicEvents(sourceFs *filesystems.SourceFilesystems, events []fs
|
||||||
func pickOneWriteOrCreatePath(events []fsnotify.Event) string {
|
func pickOneWriteOrCreatePath(events []fsnotify.Event) string {
|
||||||
name := ""
|
name := ""
|
||||||
|
|
||||||
// Some editors (for example notepad.exe on Windows) triggers a change
|
|
||||||
// both for directory and file. So we pick the longest path, which should
|
|
||||||
// be the file itself.
|
|
||||||
for _, ev := range events {
|
for _, ev := range events {
|
||||||
if (ev.Op&fsnotify.Write == fsnotify.Write || ev.Op&fsnotify.Create == fsnotify.Create) && len(ev.Name) > len(name) {
|
if ev.Op&fsnotify.Write == fsnotify.Write || ev.Op&fsnotify.Create == fsnotify.Create {
|
||||||
name = ev.Name
|
if files.IsIndexContentFile(ev.Name) {
|
||||||
|
return ev.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
if files.IsContentFile(ev.Name) {
|
||||||
|
name = ev.Name
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,16 @@ func IsContentFile(filename string) bool {
|
||||||
return contentFileExtensionsSet[strings.TrimPrefix(filepath.Ext(filename), ".")]
|
return contentFileExtensionsSet[strings.TrimPrefix(filepath.Ext(filename), ".")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsIndexContentFile(filename string) bool {
|
||||||
|
if !IsContentFile(filename) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
base := filepath.Base(filename)
|
||||||
|
|
||||||
|
return strings.HasPrefix(base, "index.") || strings.HasPrefix(base, "_index.")
|
||||||
|
}
|
||||||
|
|
||||||
func IsHTMLFile(filename string) bool {
|
func IsHTMLFile(filename string) bool {
|
||||||
return htmlFileExtensionsSet[strings.TrimPrefix(filepath.Ext(filename), ".")]
|
return htmlFileExtensionsSet[strings.TrimPrefix(filepath.Ext(filename), ".")]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue