internal/frontend: fix pageTitle for v2+ module versions

At the moment, the page title for a module version with a major version
of v2 of higher is the major version. It is now changed to the last
element of the module path.

For example, the title for mvdan.cc/sh/v3 is now sh instead of v3.

Change-Id: Idaf26bb87d7abb8ab2f8a7a15c8641d089ccdb25
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/275298
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/frontend/header.go b/internal/frontend/header.go
index 850db01..37a5378 100644
--- a/internal/frontend/header.go
+++ b/internal/frontend/header.go
@@ -33,7 +33,8 @@
 	case um.IsPackage():
 		return um.Name
 	case um.IsModule():
-		return path.Base(um.Path)
+		prefix, _, _ := module.SplitPathVersion(um.Path)
+		return path.Base(prefix)
 	default:
 		return path.Base(um.Path) + "/"
 	}
diff --git a/internal/frontend/header_test.go b/internal/frontend/header_test.go
index 5c83001..ffac4d0 100644
--- a/internal/frontend/header_test.go
+++ b/internal/frontend/header_test.go
@@ -49,6 +49,9 @@
 	m2.Units[0].Name = "main"
 	tests = append(tests, &testUnitPage{&m2.Units[0].UnitMeta, "module golang.org/x/tools/gopls", "gopls", pageTypeCommand, []string{pageTypeCommand, pageTypeModule}})
 
+	m3 := sample.Module("mvdan.cc/sh/v3", "v3.0.0")
+	tests = append(tests, &testUnitPage{&m3.Units[0].UnitMeta, "module mvdan.cc/sh/v3", "sh", pageTypeModule, []string{pageTypeModule}})
+
 	std := sample.Module(stdlib.ModulePath, "v1.0.0", "cmd/go")
 	for _, u := range std.Units {
 		um := &u.UnitMeta