aboutsummaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
authorMaria <m5ka+github@posteo.de>2024-05-21 19:09:28 +0100
committerGitHub <noreply@github.com>2024-05-21 11:09:28 -0700
commitd9a9a9071d16c779a390d94666f736e1e96c48dc (patch)
tree6d4a677f2fda60ba3c99c08a47d15b559fd739de /handler.go
parente6df748e5cbb326b77dac6086bff78ac814e1708 (diff)
downloadsally-d9a9a9071d16c779a390d94666f736e1e96c48dc.tar.gz
feat: Allow packages to define custom documentation URL and badge (#147)
feat: Allow packages to define custom doc URL and badge Co-authored-by: Jacob Oaks <jacoboaks.8@gmail.com> Co-authored-by: r-hang <rhang@uber.com>
Diffstat (limited to '')
-rw-r--r--handler.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/handler.go b/handler.go
index d25ed38..74f6a31 100644
--- a/handler.go
+++ b/handler.go
@@ -57,13 +57,23 @@ func CreateHandler(config *Config, templates *template.Template) (http.Handler,
baseURL = pkg.URL
}
modulePath := path.Join(baseURL, name)
- docURL := "https://" + path.Join(config.Godoc.Host, modulePath)
+
+ docURL := pkg.DocURL
+ if docURL == "" {
+ docURL = "https://" + path.Join(config.Godoc.Host, modulePath)
+ }
+
+ docBadge := pkg.DocBadge
+ if docBadge == "" {
+ docBadge = "//pkg.go.dev/badge/" + modulePath + ".svg"
+ }
pkg := &sallyPackage{
Name: name,
Desc: pkg.Desc,
ModulePath: modulePath,
DocURL: docURL,
+ DocBadge: docBadge,
VCS: pkg.VCS,
RepoURL: pkg.Repo,
}
@@ -106,6 +116,9 @@ type sallyPackage struct {
// URL at which documentation for the package can be found.
DocURL string
+ // URL at which documentation badge image can be found.
+ DocBadge string
+
// Version control system used by the package.
VCS string