perf: embed challenge data in HTML (#279)

This commit is contained in:
Ryan Cao 2025-04-18 04:06:37 +00:00 committed by GitHub
parent 736c3ade09
commit f844dba3dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 63 additions and 42 deletions

View file

@ -2,14 +2,22 @@ package web
import (
"github.com/a-h/templ"
"github.com/TecharoHQ/anubis/lib/policy/config"
)
func Base(title string, body templ.Component) templ.Component {
return base(title, body, nil)
return base(title, body, nil, nil)
}
func BaseWithOGTags(title string, body templ.Component, ogTags map[string]string) templ.Component {
return base(title, body, ogTags)
func BaseWithChallengeAndOGTags(title string, body templ.Component, challenge string, rules *config.ChallengeRules, ogTags map[string]string) (templ.Component, error) {
return base(title, body, struct {
Challenge string `json:"challenge"`
Rules *config.ChallengeRules `json:"rules"`
}{
Challenge: challenge,
Rules: rules,
}, ogTags), nil
}
func Index() templ.Component {