shithub: hugo

Download patch

ref: a4deaeff0cfd70abfbefa6d40c0b86839a216f6d
parent: 4d115c56fac9060230fbac6181a05f7cc6d10b42
author: Bjørn Erik Pedersen <[email protected]>
date: Thu Apr 5 06:57:13 EDT 2018

Fix some livereload content regressions

Introduced in Hugo 0.38.

Fixes #4566

--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -347,8 +347,8 @@
 		return true
 	}
 
-	if cfg.whatChanged != nil && p.File != nil && cfg.whatChanged.files[p.File.Filename()] {
-		return true
+	if cfg.whatChanged != nil && p.File != nil {
+		return cfg.whatChanged.files[p.File.Filename()]
 	}
 
 	return false
@@ -708,10 +708,15 @@
 		dir += helpers.FilePathSeparator
 	}
 
-	fileTp, _ := classifyBundledFile(name)
+	fileTp, isContent := classifyBundledFile(name)
 
 	// This may be a member of a bundle. Start with branch bundles, the most specific.
 	if fileTp != bundleLeaf {
+		if fileTp == bundleNot && isContent {
+			// Branch bundles does not contain content pages as resources.
+			return dir, filename, bundleNot
+		}
+
 		for i, b := range m.branches {
 			if b == dir {
 				m.branches = append(m.branches[:i], m.branches[i+1:]...)
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -438,7 +438,7 @@
 // will return -1 if not found
 func (ps Pages) findPagePos(page *Page) int {
 	for i, x := range ps {
-		if x.Source.Path() == page.Source.Path() {
+		if x.Source.Filename() == page.Source.Filename() {
 			return i
 		}
 	}
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1225,7 +1225,8 @@
 }
 
 func (s *Site) isContentDirEvent(e fsnotify.Event) bool {
-	return s.getContentDir(e.Name) != ""
+	relDir, _ := s.PathSpec.RelContentDir(e.Name)
+	return relDir != e.Name
 }
 
 func (s *Site) getContentDir(path string) string {