feat(pages): populate pages in publisher for site generation

This commit is contained in:
Leon Mika 2026-03-22 19:09:01 +11:00
parent 255fa26a15
commit d464821a8c
2 changed files with 8 additions and 0 deletions

View file

@ -18,4 +18,5 @@ type Site struct {
Categories []models.CategoryWithCount
PostIterByCategory func(ctx context.Context, categoryID int64) iter.Seq[models.Maybe[*models.Post]]
CategoriesOfPost func(ctx context.Context, postID int64) ([]*models.Category, error)
Pages []*models.Page
}

View file

@ -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 {
if !target.Enabled {
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) {
return p.db.SelectCategoriesOfPost(ctx, postID)
},
Pages: sitePages,
OpenUpload: func(u models.Upload) (io.ReadCloser, error) {
return p.up.OpenUpload(site, u)
},