This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
structs.go
68 lines (59 loc) · 1.57 KB
/
structs.go
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
package main
import "fmt"
// client structs
type Price struct {
Free *bool `yaml:"free"`
Paid *bool `yaml:"paid"`
}
type Hoster struct {
Icon string `yaml:"icon"`
IconURL string `yaml:"icon-url"`
Text string `yaml:"text"`
URL string `yaml:"url"`
}
type Client struct {
Name string `yaml:"name"`
Targets []string `yaml:"targets"`
Types []string `yaml:"types"`
Official *bool `yaml:"official"`
Beta *bool `yaml:"beta"`
Website string `yaml:"website"`
OpenSourceURL string `yaml:"oss"`
Price Price `yaml:"price"`
Downloads []*Hoster `yaml:"downloads"`
}
// misc
type icon struct {
Light string `yaml:"light"`
Dark string `yaml:"dark"`
Single string `yaml:"single"`
Text string `yaml:"text"`
}
func (i *icon) Markdown(url string) string {
if (i.Dark != "") != (i.Light != "") {
panic("use 'single' if only single icon URL available")
}
if i.Dark != "" {
return fmt.Sprintf(`
<a href="%s">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="%s">
<source media="(prefers-color-scheme: light)" srcset="%s">
<img src="%s">
</picture>
</a>`, url, i.Light, i.Dark, i.Dark)
}
if i.Text != "" {
return fmt.Sprintf("[%s](%s)", i.Text, url)
}
return fmt.Sprintf("[![img](%s)](%s)", i.Single, url)
}
type clientsConfig struct {
Clients []*Client `yaml:"clients"`
Targets []*struct {
Key string `yaml:"key"`
Display string `yaml:"display"`
Has map[string]string `yaml:"has"`
} `yaml:"targets"`
Icons map[string]*icon `yaml:"icons"`
}