package components import ( "context" "io" "net/url" "go.alanpearce.eu/searchix/frontend" "go.alanpearce.eu/searchix/internal/config" ) templ Page(tdata TemplateData) { Searchix for _, sheet := range tdata.Assets.Stylesheets { } @Unsafe(tdata.ExtraHeadHTML) for _, source := range tdata.Sources { }
{ children... }
} templ script(s *frontend.Asset) { } func Unsafe(html string) templ.Component { return templ.ComponentFunc(func(_ context.Context, w io.Writer) (err error) { _, err = io.WriteString(w, html) return }) } func sourceNameAndType(source *config.Source) string { if source == nil { return "Combined" } switch source.Importer { case config.Options: return source.Name + " " + source.Importer.String() case config.Packages: return source.Name } return "" } func joinPath(base string, parts ...string) templ.SafeURL { u, err := url.JoinPath(base, parts...) if err != nil { panic(err) } return templ.SafeURL(u) } func joinPathQuery[T ~string](path T, query string) templ.SafeURL { if query == "" { return templ.SafeURL(path) } return templ.SafeURL(string(path) + "?query=" + url.QueryEscape(query)) }