mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
hugolib, commands: Improve live-reload on directory structure changes
This issue is more visible now that we support nested sections. This commit makes operations like pasting new content folders or deleting content folders during server watch just work. Fixes #3570
This commit is contained in:
@@ -137,6 +137,18 @@ func (c *PageCollections) addPage(page *Page) {
|
||||
c.rawAllPages = append(c.rawAllPages, page)
|
||||
}
|
||||
|
||||
// When we get a REMOVE event we're not always getting all the individual files,
|
||||
// so we need to remove all below a given path.
|
||||
func (c *PageCollections) removePageByPathPrefix(path string) {
|
||||
for {
|
||||
i := c.rawAllPages.FindPagePosByFilePathPrefix(path)
|
||||
if i == -1 {
|
||||
break
|
||||
}
|
||||
c.rawAllPages = append(c.rawAllPages[:i], c.rawAllPages[i+1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PageCollections) removePageByPath(path string) {
|
||||
if i := c.rawAllPages.FindPagePosByFilePath(path); i >= 0 {
|
||||
c.rawAllPages = append(c.rawAllPages[:i], c.rawAllPages[i+1:]...)
|
||||
|
Reference in New Issue
Block a user