aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@google.com>2021-05-17 12:56:51 -0400
committerRuss Cox <rsc@google.com>2021-05-24 23:12:15 -0400
commitef1829f24bf8bf2648d2ac4efa85a06e1fbc0e0b (patch)
tree6d405ba4c14b8073800229261e9fbaf3dc8ea49f
parent530546278fa92c85918c027f7f3e58b4e29a7757 (diff)
downloadgo-x-website-ef1829f24bf8bf2648d2ac4efa85a06e1fbc0e0b.tar.xz
[x/go.dev] all: fix mobile nav "Why Go" highlights
In the mobile menu the pages in the Google section did not highlight "Why Go" the same way as the pages in the rest of the Solutions section. This is a bug in the current web site which we were mimicking, but it seems worth fixing, which will be better UX and also simplify the code. The root cause of the problem is apparently confusion between Hugo's Section and CurrentSection. Section returns a string, and CurrentSection returns a Page, but that's not the only difference: they also use subtly different meanings of the term “section”. Specifically, Section uses the topmost section (solutions even for solutions/google or solutions/google/chrome), while CurrentSection uses any deeper section if present (solutions/google for those two cases). For the purposes of the menu, we only care about being in the top-level "solutions" section. So use that meaning in CurrentSection, diverging from Hugo but making the site better. The CurrentSection name will go away entirely later. Change-Id: I102907f347f0472527e0f48fe35280e92b9ea0d4 X-GoDev-Commit: 05f65502deea650f0d496622a9608bc212ec33b5
-rw-r--r--go.dev/cmd/internal/site/tmpl.go2
-rw-r--r--go.dev/testdata/golden/solutions/google/chrome/index.html2
-rw-r--r--go.dev/testdata/golden/solutions/google/coredata/index.html2
-rw-r--r--go.dev/testdata/golden/solutions/google/firebase/index.html2
-rw-r--r--go.dev/testdata/golden/solutions/google/index.html2
-rw-r--r--go.dev/testdata/golden/solutions/google/sitereliability/index.html2
6 files changed, 6 insertions, 6 deletions
diff --git a/go.dev/cmd/internal/site/tmpl.go b/go.dev/cmd/internal/site/tmpl.go
index 887f4182..152ed73f 100644
--- a/go.dev/cmd/internal/site/tmpl.go
+++ b/go.dev/cmd/internal/site/tmpl.go
@@ -211,7 +211,7 @@ func eval(elem reflect.Value, key string) (string, bool) {
}
func (p *Page) CurrentSection() *Page {
- return p.site.pagesByID[p.section]
+ return p.site.pagesByID[p.Section()]
}
func (p *Page) IsHome() bool { return p.id == "" }
diff --git a/go.dev/testdata/golden/solutions/google/chrome/index.html b/go.dev/testdata/golden/solutions/google/chrome/index.html
index 084a7d94..0f71e380 100644
--- a/go.dev/testdata/golden/solutions/google/chrome/index.html
+++ b/go.dev/testdata/golden/solutions/google/chrome/index.html
@@ -96,7 +96,7 @@
</a>
</div>
<ul class="NavigationDrawer-list">
- <li class="NavigationDrawer-listItem ">
+ <li class="NavigationDrawer-listItem NavigationDrawer-listItem--active">
<a href="/solutions">Why Go</a>
</li>
<li class="NavigationDrawer-listItem ">
diff --git a/go.dev/testdata/golden/solutions/google/coredata/index.html b/go.dev/testdata/golden/solutions/google/coredata/index.html
index 97570950..96558cca 100644
--- a/go.dev/testdata/golden/solutions/google/coredata/index.html
+++ b/go.dev/testdata/golden/solutions/google/coredata/index.html
@@ -96,7 +96,7 @@
</a>
</div>
<ul class="NavigationDrawer-list">
- <li class="NavigationDrawer-listItem ">
+ <li class="NavigationDrawer-listItem NavigationDrawer-listItem--active">
<a href="/solutions">Why Go</a>
</li>
<li class="NavigationDrawer-listItem ">
diff --git a/go.dev/testdata/golden/solutions/google/firebase/index.html b/go.dev/testdata/golden/solutions/google/firebase/index.html
index 91e77da4..dd25334c 100644
--- a/go.dev/testdata/golden/solutions/google/firebase/index.html
+++ b/go.dev/testdata/golden/solutions/google/firebase/index.html
@@ -96,7 +96,7 @@
</a>
</div>
<ul class="NavigationDrawer-list">
- <li class="NavigationDrawer-listItem ">
+ <li class="NavigationDrawer-listItem NavigationDrawer-listItem--active">
<a href="/solutions">Why Go</a>
</li>
<li class="NavigationDrawer-listItem ">
diff --git a/go.dev/testdata/golden/solutions/google/index.html b/go.dev/testdata/golden/solutions/google/index.html
index c5ddf6d0..696570be 100644
--- a/go.dev/testdata/golden/solutions/google/index.html
+++ b/go.dev/testdata/golden/solutions/google/index.html
@@ -96,7 +96,7 @@
</a>
</div>
<ul class="NavigationDrawer-list">
- <li class="NavigationDrawer-listItem ">
+ <li class="NavigationDrawer-listItem NavigationDrawer-listItem--active">
<a href="/solutions">Why Go</a>
</li>
<li class="NavigationDrawer-listItem ">
diff --git a/go.dev/testdata/golden/solutions/google/sitereliability/index.html b/go.dev/testdata/golden/solutions/google/sitereliability/index.html
index fb6e83c4..3c51d58c 100644
--- a/go.dev/testdata/golden/solutions/google/sitereliability/index.html
+++ b/go.dev/testdata/golden/solutions/google/sitereliability/index.html
@@ -96,7 +96,7 @@
</a>
</div>
<ul class="NavigationDrawer-list">
- <li class="NavigationDrawer-listItem ">
+ <li class="NavigationDrawer-listItem NavigationDrawer-listItem--active">
<a href="/solutions">Why Go</a>
</li>
<li class="NavigationDrawer-listItem ">