-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgithub-button.html
79 lines (73 loc) · 3.03 KB
/
github-button.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{{ $user := .Get "user" | default .Site.Params.HugoShortcodes.Github.User | default "sammcj" }}
{{ $repo := .Get "repo" | default .Site.Params.HugoShortcodes.Github.Repository | default "smcleod" }}
{{ $button := .Get "button"}}
{{ $data_icon := "mark-github" }}
{{ $aria_label := "" }}
{{ $button_text := "" }}
{{ $href := "" }}
{{if eq $button "follow"}}
{{ $href = printf "%s" (.Get "user")}}
{{ $aria_label = printf "Follow @%s on GitHub" (.Get "user") }}
{{ $button_text = printf "Follow @%s" (.Get "user") }}
{{else if eq $button "sponsor"}}
{{ $href = printf "sponsors/%s" (.Get "user")}}
{{ $data_icon = "heart" }}
{{ $aria_label = printf "Sponsor @%s on GitHub" (.Get "user") }}
{{ $button_text = "Sponsor" }}
{{else if eq $button "watch"}}
{{ $href = printf "%s/%s/subscription" (.Get "user") (.Get "repo")}}
{{ $data_icon = "eye" }}
{{ $aria_label = printf "Watch %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = "Watch" }}
{{else if eq $button "star"}}
{{ $href = printf "%s/%s/" (.Get "user") (.Get "repo")}}
{{ $data_icon = "star" }}
{{ $aria_label = printf "Star %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = "Star" }}
{{else if eq $button "fork"}}
{{ $href = printf "%s/%s/fork" (.Get "user") (.Get "repo")}}
{{ $data_icon = "repo-forked" }}
{{ $aria_label = printf "Fork %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = "Fork" }}
{{else if eq $button "template"}}
{{ $href = printf "%s/%s/generate" (.Get "user") (.Get "repo")}}
{{ $data_icon = "repo-template" }}
{{ $aria_label = printf "Use this template %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = "Use this template" }}
{{else if eq $button "issue"}}
{{ $href = printf "%s/%s/issues" (.Get "user") (.Get "repo")}}
{{ $data_icon = "issue-opened" }}
{{ $aria_label = printf "Issue %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = "Issue" }}
{{else if eq $button "download"}}
{{ $branch := default "master" (.Get "branch")}}
{{ $href = printf "%s/%s/archive/%s.zip" (.Get "user") (.Get "repo") $branch}}
{{ $data_icon = "download" }}
{{ $aria_label = printf "Download %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = "Download" }}
{{else if eq $button "view"}}
{{ $href = printf "%s/%s" (.Get "user") (.Get "repo")}}
{{ $data_icon = "mark-github" }}
{{ $aria_label = printf "View %s/%s on GitHub" (.Get "user") (.Get "repo")}}
{{ $button_text = .Get "repo" }}
{{end}}
{{ with .Get "text" }}
{{ $button_text = . }}
{{ end }}
{{ with .Get "icon" }}
{{ $data_icon = . }}
{{ end }}
{{ with .Get "aria_label" }}
{{ $aria_label = . }}
{{ end }}
<a
class="github-button"
href="https://github.com/{{$href}}"
data-icon="octicon-{{$data_icon}}"
aria-label="{{$aria_label}}"
{{ with .Get "count"}} data-show-count="{{.}}"{{ end }}
{{if eq "true" (.Get "dark")}}data-color-scheme="dark"{{ end }}
{{if eq "true" (.Get "large")}}data-size="large"{{ end }}
>
{{$button_text}}
</a>