Files
sm-seo-plugin/controllers/api/site.go
Jakub Zych 742a5b930b feat: site endpoint, llms.txt and the sitemap index in robots.txt
- GET /_seo/api/v1/site (public, noindex): site_url, default_locale,
  locales, unprefixed_locale, links.new_tab, html_sitemap (from the
  sitemap plugin's Listing), routes of every content type, root_files
  (verification files and the IndexNow key file) and llms
- GET /llms.txt: with llms_enabled (robots.txt screen, AI bots tab, off by
  default) and in production, the indexable pages from the sitemaps per
  group under the site name and llms_intro (else the default
  description); otherwise 404; seo_update_robots takes both fields
- robots.txt names the sitemap plugin's index unless
  golem15.seo.robots_sitemaps is set; the config default is now a comment
2026-11-04 13:32:12 +01:00

30 lines
943 B
Go

package api
import (
"net/http"
"git.golem15.com/golem15/sm-seo-plugin/classes"
"git.golem15.com/golem15/summercms/modules/wire"
)
// Site serves GET /_seo/api/v1/site (P33-17): the site facts the frontend
// layer needs (site URL, locales, the new-tab switch, the HTML sitemap
// settings, the content types' URL patterns, the root file names and
// whether llms.txt is served). Every value is public.
func Site(service func() *classes.Service) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
svc := service()
if svc == nil {
wire.WriteJSON(w, http.StatusServiceUnavailable, map[string]string{"error": "SEO is not available"})
return
}
out, err := svc.Site(r.Context())
if err != nil {
log.Error("golem15.seo: site answer", "error", err)
wire.WriteJSON(w, http.StatusInternalServerError, map[string]string{"error": errInternal})
return
}
wire.WriteJSON(w, http.StatusOK, out)
}
}