diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index 6ce6657fa..9241772b2 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -740,6 +740,11 @@ func (m *contentChangeMap) resolveAndRemove(filename string) (string, string, bu } } + if isContent && fileTp != bundleNot { + // A new bundle. + return dir, dir, fileTp + } + // Not part of any bundle return dir, filename, bundleNot } diff --git a/hugolib/page_bundler_capture.go b/hugolib/page_bundler_capture.go index 15a80681e..6fe413014 100644 --- a/hugolib/page_bundler_capture.go +++ b/hugolib/page_bundler_capture.go @@ -20,6 +20,7 @@ import ( "path" "path/filepath" "runtime" + "sort" "strings" "sync" @@ -71,6 +72,30 @@ func newCapturer( numWorkers = n } + // TODO(bep) the "index" vs "_index" check/strings should be moved in one place. + isBundleHeader := func(filename string) bool { + base := filepath.Base(filename) + name := helpers.Filename(base) + return isContentFile(base) && (name == "index" || name == "_index") + } + + // Make sure that any bundle header files are processed before the others. This makes + // sure that any bundle head is processed before its resources. + sort.Slice(filenames, func(i, j int) bool { + a, b := filenames[i], filenames[j] + ac, bc := isBundleHeader(a), isBundleHeader(b) + + if ac { + return true + } + + if bc { + return false + } + + return a < b + }) + c := &capturer{ sem: make(chan bool, numWorkers), handler: handler,