Phase 7 part 5: add a section to an existing page
Sites → Sections and pages → Add a section, on any page built from sections: choose one of the site's section types and where it goes; the AI writes it from the page, its searches, the profile and the Inventory, with the same rules as a new page. It's reviewed like a page (claims to confirm, to-dos), and the pull request inserts it into the page's file as text, so only that section is added; the build checks it. What to write next suggests a FAQ for a section page found with questions, and a comparison for one searched against something else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"supermarket/internal/inventory"
|
||||
"supermarket/internal/next"
|
||||
"supermarket/internal/profile"
|
||||
"supermarket/internal/seo"
|
||||
@@ -78,6 +80,12 @@ func (s *Server) nextFor(cur seoSite, now time.Time) (list []next.Suggestion, mo
|
||||
all = append(all, next.MentionSuggestions(ms, p)...)
|
||||
}
|
||||
}
|
||||
// Sections for pages already on the site, from what they're searched for.
|
||||
if cur.Property != "" {
|
||||
if ideas, err := s.sectionIdeas(cur); err == nil {
|
||||
all = append(all, ideas...)
|
||||
}
|
||||
}
|
||||
stalled, err := next.Stalled(s.DB, cur.URL, cur.Index, now)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -152,3 +160,52 @@ func (s *Server) seoNextDismiss(w http.ResponseWriter, r *http.Request) {
|
||||
idx, _ := strconv.Atoi(r.URL.Query().Get("site"))
|
||||
redirect(w, r, "/seo/next?site="+strconv.Itoa(idx), "next-dismissed")
|
||||
}
|
||||
|
||||
// sectionIdeas suggest a FAQ or a comparison for the site's section pages,
|
||||
// from the searches that bring people to them.
|
||||
func (s *Server) sectionIdeas(cur seoSite) ([]next.Suggestion, error) {
|
||||
var repo *siteRepo
|
||||
for _, sr := range s.siteRepos() {
|
||||
if sr.URL == cur.URL && sr.Repo != "" {
|
||||
r := sr
|
||||
repo = &r
|
||||
}
|
||||
}
|
||||
if repo == nil {
|
||||
return nil, nil
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
cat, err := s.catalog(ctx, *repo, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var pages []next.SectionPage
|
||||
for _, pg := range cat.Pages {
|
||||
if pg.Sections && !pg.Draft {
|
||||
pages = append(pages, next.SectionPage{Path: pg.Path, Title: pg.Title, Types: pg.Types})
|
||||
}
|
||||
}
|
||||
var types []string
|
||||
for _, t := range cat.Types {
|
||||
if !t.Missing {
|
||||
types = append(types, t.Name)
|
||||
}
|
||||
}
|
||||
sc := s.scope(cur)
|
||||
searches, err := seo.SearchesByPath(s.DB, sc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var competitors []string
|
||||
if entries, err := inventory.List(s.DB, "competitor"); err == nil {
|
||||
for _, e := range entries {
|
||||
competitors = append(competitors, e.Name)
|
||||
}
|
||||
}
|
||||
if p, _ := profile.Load(s.DB); p != nil {
|
||||
competitors = append(competitors, p.Targets.Technologies...)
|
||||
}
|
||||
rate, _ := sc.Rate("")
|
||||
return next.SectionIdeas(pages, searches, types, competitors, cur.Index, rate), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user