2017-06-22 23:37:46 +02:00
|
|
|
package server
|
|
|
|
|
2017-07-09 15:37:23 +02:00
|
|
|
func (s *Server) watchAndReload() error {
|
|
|
|
site := s.Site
|
2017-07-15 03:19:01 +02:00
|
|
|
return site.WatchFiles(func(filenames []string) {
|
2017-07-14 20:52:31 +02:00
|
|
|
// This resolves filenames to URLS *before* reloading the site, in case the latter
|
2017-07-09 15:37:23 +02:00
|
|
|
// remaps permalinks.
|
|
|
|
urls := map[string]bool{}
|
|
|
|
for _, relpath := range filenames {
|
|
|
|
url, ok := site.FilenameURLPath(relpath)
|
|
|
|
if ok {
|
|
|
|
urls[url] = true
|
|
|
|
}
|
|
|
|
}
|
2017-07-15 14:59:19 +02:00
|
|
|
s.reload(len(filenames))
|
2017-07-09 15:37:23 +02:00
|
|
|
for url := range urls {
|
|
|
|
s.lr.Reload(url)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|