Add SSR for compliance page with dynamic title and meta tags

Implement server-side rendering of trust center page `<head>` with dynamic organization name and OG meta tags. Adds generic `FileRenderer` mechanism to statichandler for dynamic file rendering, allowing the trust server to inject templated content at request time.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-18 15:55:18 +01:00
parent ea21f85887
commit 751d9eb1f3
5 changed files with 177 additions and 51 deletions

View File

@@ -37,6 +37,7 @@ import (
console_web "go.probo.inc/probo/pkg/server/web"
"go.probo.inc/probo/pkg/slack"
"go.probo.inc/probo/pkg/trust"
"go.gearno.de/x/ref"
)
type Config struct {
@@ -97,7 +98,7 @@ func NewServer(cfg Config) (*Server, error) {
return nil, err
}
trustWebServer, err := trust_web.NewServer()
trustWebServer, err := trust_web.NewServer(compliancePageHeadData(cfg.Trust))
if err != nil {
return nil, err
}
@@ -195,3 +196,25 @@ func (s *Server) TrustCenterHandler() http.Handler {
return r
}
func compliancePageHeadData(trustService *trust.Service) trust_web.HeadDataFunc {
return func(r *http.Request) trust_web.HeadData {
tc := compliancepage.CompliancePageFromContext(r.Context())
if tc == nil {
return trust_web.HeadData{Title: "Compliance Page"}
}
org, err := trustService.GetOrganizationByTrustCenterID(r.Context(), tc.ID)
if err != nil || org == nil {
return trust_web.HeadData{Title: "Compliance Page"}
}
baseURL := compliancepage.CompliancePageBaseURLFromContext(r.Context())
return trust_web.HeadData{
Title: org.Name + " — Compliance",
Description: org.Name + " Compliance Page",
OGURL: ref.UnrefOrZero(baseURL),
}
}
}