Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions router/anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ func (a *anchor) onClick(_ *vecty.Event) {
}

// Render implements vecty.Component
func (a *anchor) Render() *vecty.HTML {
func (a *anchor) Render() vecty.ComponentOrHTML {
return elem.Anchor(
prop.Href(`javascript:;`),
event.Click(a.onClick).PreventDefault().StopPropagation(),
vecty.Markup(
prop.Href(`javascript:;`),
event.Click(a.onClick).PreventDefault().StopPropagation(),
),
a.children,
)
}

// LinkWithParams wraps the provided content in an anchor tag that transitions
// to a new location with URL parameters on click.
func LinkWithParams(path string, params url.Values, content vecty.ComponentOrHTML) vecty.MarkupOrComponentOrHTML {
func LinkWithParams(path string, params url.Values, content vecty.ComponentOrHTML) vecty.ComponentOrHTML {
return &anchor{path: path, params: params, children: content}
}

// Link wraps the provided content in an anchor tag that transitions to a new
// location on click.
func Link(path string, content vecty.ComponentOrHTML) vecty.MarkupOrComponentOrHTML {
func Link(path string, content vecty.ComponentOrHTML) vecty.ComponentOrHTML {
return LinkWithParams(path, nil, content)
}
4 changes: 2 additions & 2 deletions router/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func (b *body) OnRoute(ctx Context) {
}

// Render implements vecty.Component
func (b *body) Render() *vecty.HTML {
func (b *body) Render() vecty.ComponentOrHTML {
return elem.Body(
prop.ID(`Body`),
vecty.Markup(prop.ID(`Body`)),
b.children,
)
}