diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-06-08 20:00:05 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-06-08 20:14:28 +0200 |
commit | fe901b81191860b60e6fcb29f8ebf87baef2ee79 (patch) | |
tree | d2a3d58c28f826b602f81973fc0e7dbaec4c697b /hugolib/page.go | |
parent | b39689393ccb8434d9a57658a64b77568c718e99 (diff) |
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
Diffstat (limited to 'hugolib/page.go')
-rw-r--r-- | hugolib/page.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hugolib/page.go b/hugolib/page.go index cb9a28f24..42ed4e60f 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -322,6 +322,18 @@ func (ps Pages) FindPagePosByFilePath(inPath string) int { return -1 } +func (ps Pages) FindPagePosByFilePathPrefix(prefix string) int { + if prefix == "" { + return -1 + } + for i, x := range ps { + if strings.HasPrefix(x.Source.Path(), prefix) { + return i + } + } + return -1 +} + // FindPagePos Given a page, it will find the position in Pages // will return -1 if not found func (ps Pages) FindPagePos(page *Page) int { |