content/internal: show message when repo url is unavailable
When the repo url is unavailable show a message in the
right sidebar.
Change-Id: I1a54ff674f1f1e514a0af3cc98ad4ec62755e839
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/262680
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/content/static/html/helpers/_unit_meta.tmpl b/content/static/html/helpers/_unit_meta.tmpl
index ac3ecf6..1430c5d 100644
--- a/content/static/html/helpers/_unit_meta.tmpl
+++ b/content/static/html/helpers/_unit_meta.tmpl
@@ -8,8 +8,12 @@
<div class="UnitMeta">
<div class="UnitMeta-header">Links</div>
<div class="UnitMeta-repo">Repository</div>
- <a href="{{.Unit.SourceInfo.RepoURL}}" title="{{.Unit.SourceInfo.RepoURL}}">
- {{.Unit.SourceInfo.RepoURL}}
- </a>
+ {{if .Details.RepositoryURL}}
+ <a href="{{.Details.RepositoryURL}}" title="{{.Details.RepositoryURL}}" target="_blank" rel="noopener">
+ {{.Details.RepositoryURL}}
+ </a>
+ {{else}}
+ Repository URL not available.
+ {{end}}
</div>
{{end}}
diff --git a/internal/frontend/unit_main.go b/internal/frontend/unit_main.go
index b7c6382..772d507 100644
--- a/internal/frontend/unit_main.go
+++ b/internal/frontend/unit_main.go
@@ -54,6 +54,9 @@
// SourceFiles contains .go files for the package.
SourceFiles []*File
+ // RepositoryURL is the URL to the repository containing the package.
+ RepositoryURL string
+
// ExpandReadme is holds the expandable readme state.
ExpandReadme bool
}
@@ -166,6 +169,7 @@
DocOutline: docOutline,
DocBody: docBody,
SourceFiles: files,
+ RepositoryURL: um.SourceInfo.RepoURL(),
MobileOutline: mobileOutline,
NumImports: len(unit.Imports),
ImportedByCount: importedByCount,