doc: format stars count (#281)
Use the k format for thousands, just like Github itself.
This commit is contained in:
committed by
GitHub
parent
224b6bf249
commit
4ca3d8a29f
@@ -193,19 +193,19 @@ Implementations of full algorithms:
|
|||||||
Popular projects using `avo`:
|
Popular projects using `avo`:
|
||||||
|
|
||||||
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fgolang.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [golang / **go**](https://github.com/golang/go)
|
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fgolang.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [golang / **go**](https://github.com/golang/go)
|
||||||
:star: 98831
|
:star: 98.8k
|
||||||
> The Go programming language
|
> The Go programming language
|
||||||
|
|
||||||
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fklauspost.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [klauspost / **compress**](https://github.com/klauspost/compress)
|
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fklauspost.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [klauspost / **compress**](https://github.com/klauspost/compress)
|
||||||
:star: 2894
|
:star: 2.9k
|
||||||
> Optimized Go Compression Packages
|
> Optimized Go Compression Packages
|
||||||
|
|
||||||
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fgolang.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [golang / **crypto**](https://github.com/golang/crypto)
|
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fgolang.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [golang / **crypto**](https://github.com/golang/crypto)
|
||||||
:star: 2416
|
:star: 2.4k
|
||||||
> [mirror] Go supplementary cryptography libraries
|
> [mirror] Go supplementary cryptography libraries
|
||||||
|
|
||||||
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fklauspost.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [klauspost / **reedsolomon**](https://github.com/klauspost/reedsolomon)
|
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fklauspost.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [klauspost / **reedsolomon**](https://github.com/klauspost/reedsolomon)
|
||||||
:star: 1444
|
:star: 1.4k
|
||||||
> Reed-Solomon Erasure Coding in Go
|
> Reed-Solomon Erasure Coding in Go
|
||||||
|
|
||||||
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fsegmentio.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [segmentio / **asm**](https://github.com/segmentio/asm)
|
<img src="https://images.weserv.nl?fit=cover&h=24&mask=circle&maxage=7d&url=https%3A%2F%2Fgithub.com%2Fsegmentio.png&w=24" width="24" height="24" hspace="4" valign="middle" /> [segmentio / **asm**](https://github.com/segmentio/asm)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -45,6 +46,7 @@ func mainerr() (err error) {
|
|||||||
"include": include,
|
"include": include,
|
||||||
"snippet": snippet,
|
"snippet": snippet,
|
||||||
"avatar": avatar,
|
"avatar": avatar,
|
||||||
|
"stars": stars,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Load template.
|
// Load template.
|
||||||
@@ -191,3 +193,12 @@ func avatar(owner string, size int) (string, error) {
|
|||||||
format := `<img src="%s" width="%d" height="%d" hspace="4" valign="middle" />`
|
format := `<img src="%s" width="%d" height="%d" hspace="4" valign="middle" />`
|
||||||
return fmt.Sprintf(format, src.String(), size, size), nil
|
return fmt.Sprintf(format, src.String(), size, size), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stars formats a Github star count, rounding to thousands in the same style as Github.
|
||||||
|
func stars(n int) string {
|
||||||
|
if n < 1000 {
|
||||||
|
return strconv.Itoa(n)
|
||||||
|
}
|
||||||
|
k := math.Round(float64(n)/100.0) / 10.0
|
||||||
|
return strconv.FormatFloat(k, 'f', -1, 64) + "k"
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ Popular projects using `avo`:
|
|||||||
{{ range .Projects.Top 10 -}}
|
{{ range .Projects.Top 10 -}}
|
||||||
{{ if lt .Metadata.Stars 100 }}{{break}}{{ end -}}
|
{{ if lt .Metadata.Stars 100 }}{{break}}{{ end -}}
|
||||||
{{ avatar .Repository.Owner 24 }} [{{ .Repository.Owner }} / **{{ .Repository.Name }}**]({{ .Repository.URL }})
|
{{ avatar .Repository.Owner 24 }} [{{ .Repository.Owner }} / **{{ .Repository.Name }}**]({{ .Repository.URL }})
|
||||||
:star: {{ .Metadata.Stars }}
|
:star: {{ stars .Metadata.Stars }}
|
||||||
> {{ .Metadata.Description }}
|
> {{ .Metadata.Description }}
|
||||||
|
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user