content,internal: add the doc index to the unit page

Adds css to unhide the doc index on the unit page and
an index link in the sidenav that is hidden on the
package details page.

Change-Id: Ieffe1368aaa1fc7cfcd4250359279b94d18a500b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/256537
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/content/static/css/sidenav.css b/content/static/css/sidenav.css
index 8faf010..de2ea7a 100644
--- a/content/static/css/sidenav.css
+++ b/content/static/css/sidenav.css
@@ -16,7 +16,8 @@
 }
 .Documentation-nav,
 .Documentation-index,
-.DocNav {
+.DocNav,
+.DocNav-index {
   display: none;
 }
 .DocNavMobile {
diff --git a/content/static/css/unit_outline.css b/content/static/css/unit_outline.css
index 0eb375e..eee34b6 100644
--- a/content/static/css/unit_outline.css
+++ b/content/static/css/unit_outline.css
@@ -4,6 +4,11 @@
  * license that can be found in the LICENSE file.
  */
 
+.Documentation-index,
+.DocNav,
+.DocNav-index {
+  display: block;
+}
 .DocNav {
   max-height: calc(100vh - var(--header-height));
   overflow-x: unset;
@@ -38,5 +43,5 @@
   padding: 0 18px;
   background-color: white;
   display: block;
-  overflow: scroll;
+  overflow-y: auto;
 }
diff --git a/internal/fetch/dochtml/template_sidenav.go b/internal/fetch/dochtml/template_sidenav.go
index df7e603..5cd57fc 100644
--- a/internal/fetch/dochtml/template_sidenav.go
+++ b/internal/fetch/dochtml/template_sidenav.go
@@ -19,6 +19,11 @@
 					<a href="#pkg-overview" role="treeitem" aria-level="1" tabindex="0">Overview</a>
 				</li>
 			{{end}}
+			{{- if or .Consts .Vars .Funcs .Types .Examples.List -}}
+				<li class="DocNav-index" role="none">
+					<a href="#pkg-index" role="treeitem" aria-level="1" tabindex="0">Index</a>
+				</li>
+			{{end}}
 			{{if .Examples.List}}
 				<li class="DocNav-examples" role="none">
 					<a href="#pkg-examples" role="treeitem" aria-level="1" tabindex="-1">Examples</a>
diff --git a/internal/fetch/dochtml/template_test.go b/internal/fetch/dochtml/template_test.go
index 1570c46..3cec720 100644
--- a/internal/fetch/dochtml/template_test.go
+++ b/internal/fetch/dochtml/template_test.go
@@ -28,6 +28,11 @@
 					<a href="#pkg-overview" role="treeitem" aria-level="1" tabindex="0">Overview</a>
 				</li>
 			{{end}}
+			{{- if or .Consts .Vars .Funcs .Types .Examples.List -}}
+				<li class="DocNav-index" role="none">
+					<a href="#pkg-index" role="treeitem" aria-level="1" tabindex="0">Index</a>
+				</li>
+			{{end}}
 			{{if .Examples.List}}
 				<li class="DocNav-examples" role="none">
 					<a href="#pkg-examples" role="treeitem" aria-level="1" tabindex="-1">Examples</a>