From f844dba3dcfc0c51bcc72bfe9707ceec0c09b7ed Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Fri, 18 Apr 2025 04:06:37 +0000 Subject: perf: embed challenge data in HTML (#279) --- web/index.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'web/index.go') diff --git a/web/index.go b/web/index.go index 5d2957b..ac4cbda 100644 --- a/web/index.go +++ b/web/index.go @@ -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 { -- cgit v1.2.3