feat(pages): populate pages in publisher for site generation
This commit is contained in:
parent
255fa26a15
commit
d464821a8c
|
|
@ -18,4 +18,5 @@ type Site struct {
|
||||||
Categories []models.CategoryWithCount
|
Categories []models.CategoryWithCount
|
||||||
PostIterByCategory func(ctx context.Context, categoryID int64) iter.Seq[models.Maybe[*models.Post]]
|
PostIterByCategory func(ctx context.Context, categoryID int64) iter.Seq[models.Maybe[*models.Post]]
|
||||||
CategoriesOfPost func(ctx context.Context, postID int64) ([]*models.Category, error)
|
CategoriesOfPost func(ctx context.Context, postID int64) ([]*models.Category, error)
|
||||||
|
Pages []*models.Page
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,12 @@ func (p *Publisher) Publish(ctx context.Context, site models.Site) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch pages
|
||||||
|
sitePages, err := p.db.SelectPagesOfSite(ctx, site.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
if !target.Enabled {
|
if !target.Enabled {
|
||||||
continue
|
continue
|
||||||
|
|
@ -84,6 +90,7 @@ func (p *Publisher) Publish(ctx context.Context, site models.Site) error {
|
||||||
CategoriesOfPost: func(ctx context.Context, postID int64) ([]*models.Category, error) {
|
CategoriesOfPost: func(ctx context.Context, postID int64) ([]*models.Category, error) {
|
||||||
return p.db.SelectCategoriesOfPost(ctx, postID)
|
return p.db.SelectCategoriesOfPost(ctx, postID)
|
||||||
},
|
},
|
||||||
|
Pages: sitePages,
|
||||||
OpenUpload: func(u models.Upload) (io.ReadCloser, error) {
|
OpenUpload: func(u models.Upload) (io.ReadCloser, error) {
|
||||||
return p.up.OpenUpload(site, u)
|
return p.up.OpenUpload(site, u)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue