package handler import ( "net/http" "github.com/LMBishop/scrapbook/pkg/config" "github.com/LMBishop/scrapbook/pkg/index" "github.com/LMBishop/scrapbook/web/command/html" . "maragu.dev/gomponents" ghttp "maragu.dev/gomponents/http" ) func GetSite(mainConfig *config.MainConfig, index *index.SiteIndex) func(http.ResponseWriter, *http.Request) { return ghttp.Adapt(func(w http.ResponseWriter, r *http.Request) (Node, error) { siteName := r.PathValue("site") if siteName == "" { return html.ErrorPage("Unknown site: " + siteName), nil } site := index.GetSite(siteName) if site == nil { return html.ErrorPage("Unknown site: " + siteName), nil } return html.SitePage(mainConfig, site), nil }) }