dmitri.shuralyov.com/html/belt

add OnClick field to CommitID

For home's changesapp to be able to navigate to historyapp directly 
via SPA.
dmitshur committed 10 months ago commit d8009a3578d1be4dafb93e9ee4894d2bbd2b5e3b
Showing partial commit. Full Commit
Collapse all
belt.go
@@ -189,10 +189,11 @@ func firstParagraph(s string) string {

// CommitID is a component that displays a commit ID. E.g., "c0de1234".
type CommitID struct {
	SHA     string
	HTMLURL string // Optional.
	OnClick string // Optional.
}

func (c CommitID) Render() []*html.Node {
	sha := &html.Node{
		Type: html.ElementNode, Data: atom.Code.String(),
@@ -208,10 +209,13 @@ func (c CommitID) Render() []*html.Node {
			Attr: []html.Attribute{
				{Key: atom.Href.String(), Val: c.HTMLURL},
			},
			FirstChild: sha,
		}
		if c.OnClick != "" {
			sha.Attr = append(sha.Attr, html.Attribute{Key: atom.Onclick.String(), Val: c.OnClick})
		}
	}
	return []*html.Node{sha}
}

// Reference is a component that displays a reference (branch or tag). E.g., "main".