- saving with IndexNow on generates a 32-hex key (crypto/rand);
indexnow_new_key generates a new one, so the old key file answers 404
- GET /_sitemap/indexnow/{file} serves <key>.txt as text/plain while
IndexNow is on; the SEO layer maps it to the site root
- after each rebuild in production the added, changed and removed
addresses on the site host are queued as golem15.sitemap.indexnow jobs
(at most 10 000 per request, five attempts)
- the job posts {host, key, urlList} to api.indexnow.org through a
fetchguard client limited to that host and records the answer; 429 and
5xx retry, 400, 403 and 422 do not
- the IndexNow tab shows the S2 status partial: key or no key, last
notification or never, and the 403, 422 and 429 callouts
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package sitemap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.golem15.com/golem15/sm-sitemap-plugin/classes"
|
|
"git.golem15.com/golem15/summercms/modules/conga"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
// Jobs registers the rebuild job (classes.RebuildKind) and the IndexNow
|
|
// job (classes.IndexNowKind, five attempts: 429 and 5xx answers retry) on
|
|
// conga.
|
|
func (p *Plugin) Jobs() []pact.Job {
|
|
return []pact.Job{
|
|
conga.Job(p.rebuild, conga.MaxAttempts(3)),
|
|
conga.Job(p.indexNow, conga.MaxAttempts(classes.IndexNowAttempts)),
|
|
}
|
|
}
|
|
|
|
// indexNow sends one IndexNow request (classes.SendIndexNow).
|
|
func (p *Plugin) indexNow(ctx context.Context, args classes.IndexNowArgs) error {
|
|
return classes.SendIndexNow(ctx, p.app, args)
|
|
}
|
|
|
|
// rebuild runs one rebuild of the slot table. It ends the debounce window
|
|
// first, so record events during the rebuild queue the next one.
|
|
func (p *Plugin) rebuild(ctx context.Context, _ classes.RebuildArgs) error {
|
|
if err := classes.ClearPending(ctx, p.app); err != nil {
|
|
return err
|
|
}
|
|
res, err := classes.Rebuild(ctx, p.app)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pluginLog.Info("golem15.sitemap: rebuilt", "listed", res.Listed, "files", res.Files, "added", len(res.Added), "changed", len(res.Changed), "removed", len(res.Removed))
|
|
return nil
|
|
}
|