all repos — gopkgs @ d378084c72c2d3b7b198838357b17f279e506453

Go module vanity import paths

show badges from pkg.go.dev

Alan Pearce
commit

d378084c72c2d3b7b198838357b17f279e506453

parent

b70c509077939606bb065917d62ed7e1bd683de6

2 files changed, 10 insertions(+), 1 deletion(-)

changed files
M main.gomain.go
@@ -69,6 +69,10 @@ func godocURL(config *Config, pkg string) string {
return must(url.JoinPath("https://pkg.go.dev", packageImportPath(config, pkg))) } +func badgeURL(config *Config, pkg string) string { + return must(url.JoinPath("https://pkg.go.dev/badge/", packageImportPath(config, pkg))) +} + func packageImportPath(config *Config, pkg string) string { return config.Domain.JoinPath(pkg).String() }
M templates.gotemplates.go
@@ -150,5 +150,10 @@ )
} func GodocBadge(config *Config, pkg string) g.Node { - return A(Href(godocURL(config, pkg)), g.Text("Go Reference")) + return A(Href(godocURL(config, pkg)), + Img( + Alt("Go Reference"), + Src(badgeURL(config, pkg)+".svg"), + ), + ) }