func GetNamedVar(c vecty.Component) map[string]string {
	vars := map[string]string{}
	var givenRoute *Route
	for _, r := range routes {
		if r.c == c {
			givenRoute = r
			break
		}
	}
	if givenRoute == nil || givenRoute.p == nil {
		return vars
	}
	namedVars := hasNamedVar.FindAllString(givenRoute.pattern, -1)
	for i := 0; i < len(namedVars); i++ {
		namedVars[i] = strings.Replace(
			strings.Replace(namedVars[i], "{", "", 1),
			"}",
			"",
			1,
		)
	}
	namedValues := givenRoute.p.FindAllStringSubmatch(pathname(), -1)[0][1:]
	for i := 0; i < len(namedVars); i++ {
		vars[namedVars[i]] = namedValues[i]
	}
	return vars
}
GetNamedVar returns the parsed named variables from a URL.
If you did NewRoute("/blog/{id}", someComponent{}).
Then you can do GetNamedVar(someComponent{})
and get a map like this: {"id": "id-var"}
package router
import (
	"regexp"
	"strings"
	"syscall/js"
	fmt "github.com/cathalgarvey/fmtless"
	"github.com/hexops/vecty"
)
var routes = []*Route{}
var hasNamedVar = regexp.MustCompile("{[^/]+}")
type Route struct {
	vecty.Core
	pattern string
	c       vecty.Component
	p       *regexp.Regexp
}
type NewRouteOpts struct {
	ExactMatch bool
}
func NewRoute(pattern string, c vecty.Component, opts NewRouteOpts) *Route {
	r := &Route{
		pattern: pattern,
		c:       c,
	}
	routePattern := pattern
	if hasNamedVar.MatchString(pattern) {
		routePattern = hasNamedVar.ReplaceAllString(pattern, "([^/]+)")
	}
	if opts.ExactMatch {
		routePattern = fmt.Sprintf("^%v$", routePattern)
	}
	r.p = regexp.MustCompile(routePattern)
	register(r)
	return r
}
func (r *Route) Render() vecty.ComponentOrHTML {
	path := pathname()
	if r.p.MatchString(path) {
		return r.c
	}
	return nil
}