Fixed handling of content only vs structural page changes.
This commit is contained in:
parent
573517565d
commit
3cf4294e87
2 changed files with 58 additions and 4 deletions
|
|
@ -64,6 +64,17 @@ func (s *Service) RebuildSite(oldSite, newSite models.Site) models.Job {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Service) RebuildSiteContent(oldSite, newSite models.Site) models.Job {
|
||||
return models.Job{
|
||||
Do: func(ctx context.Context) error {
|
||||
s.signalSiteBuildingStarted(ctx, newSite)
|
||||
defer s.signalSiteBuildingFinished(ctx, newSite)
|
||||
|
||||
return s.rebuildContent(ctx, oldSite, newSite)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) rebuildSite(ctx context.Context, oldSite, newSite models.Site) error {
|
||||
// Teardown the existing site
|
||||
siteDir := s.hugo.SiteStagingDir(oldSite, hugo.BaseSiteDir)
|
||||
|
|
@ -75,6 +86,28 @@ func (s *Service) rebuildSite(ctx context.Context, oldSite, newSite models.Site)
|
|||
return err
|
||||
}
|
||||
|
||||
if err := s.writeAllContent(ctx, newSite); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.publish(ctx, newSite)
|
||||
}
|
||||
|
||||
func (s *Service) rebuildContent(ctx context.Context, oldSite, newSite models.Site) error {
|
||||
// Teardown the existing site
|
||||
siteDir := s.hugo.SiteStagingDir(oldSite, hugo.ContentSiteDir)
|
||||
if err := os.RemoveAll(siteDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.writeAllContent(ctx, newSite); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.publish(ctx, newSite)
|
||||
}
|
||||
|
||||
func (s *Service) writeAllContent(ctx context.Context, newSite models.Site) error {
|
||||
if err := s.writeAllPosts(ctx, newSite); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -83,7 +116,7 @@ func (s *Service) rebuildSite(ctx context.Context, oldSite, newSite models.Site)
|
|||
return err
|
||||
}
|
||||
|
||||
return s.publish(ctx, newSite)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) fullRebuildNecessary(ctx context.Context, site models.Site) (bool, error) {
|
||||
|
|
@ -152,4 +185,3 @@ func (s *Service) signalSiteBuildingStarted(ctx context.Context, site models.Sit
|
|||
func (s *Service) signalSiteBuildingFinished(ctx context.Context, site models.Site) {
|
||||
s.bus.Fire(models.Event{Type: models.EventSiteBuildingDone, Data: site})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue