blob: 73ea1a097b79960d8b3b0e992655606e2d076f94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package handler
import (
"fmt"
"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 nil, fmt.Errorf("unknown site")
}
site := index.GetSite(siteName)
if site == nil {
return nil, fmt.Errorf("unknown site")
}
return html.SitePage(mainConfig, site), nil
})
}
|