From ef1829f24bf8bf2648d2ac4efa85a06e1fbc0e0b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 17 May 2021 12:56:51 -0400 Subject: [x/go.dev] all: fix mobile nav "Why Go" highlights MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- go.dev/cmd/internal/site/tmpl.go | 2 +- go.dev/testdata/golden/solutions/google/chrome/index.html | 2 +- go.dev/testdata/golden/solutions/google/coredata/index.html | 2 +- go.dev/testdata/golden/solutions/google/firebase/index.html | 2 +- go.dev/testdata/golden/solutions/google/index.html | 2 +- go.dev/testdata/golden/solutions/google/sitereliability/index.html | 2 +- 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 @@