_content/ref: specify redirect for /ref and /ref/ using /ref/index.md

We want both `/ref` and `/ref/` to point to `/doc/#references` section.
All documents for /ref/* are available from this unified website, so we
can set up a redirect rule using the native redirect support provided by
the internal/web package instead of relying on the internal/redirect rule.

Fixes golang/go#53243

Change-Id: Ibed1aefc82f8b93ae14775efbb456b1571053eda
Reviewed-on: https://go-review.googlesource.com/c/website/+/413914
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Hana (Hyang-Ah) Kim 2022-06-23 22:31:18 -04:00 коммит произвёл Hyang-Ah Hana Kim
Родитель 4056b246ea
Коммит 6b9583b283
4 изменённых файлов: 9 добавлений и 7 удалений

3
_content/ref/index.md Normal file
Просмотреть файл

@ -0,0 +1,3 @@
<!--{
"Redirect": "/doc/#references"
}-->

6
cmd/golangorg/testdata/web.txt поставляемый
Просмотреть файл

@ -422,3 +422,9 @@ redirect == https://go.dev/dl/?mode=json
GET https://go.dev/dl/?mode=json
body contains .windows-amd64.msi
body !contains UA-
GET https://go.dev/ref
redirect == /doc/#references
GET https://go.dev/ref/
redirect == /doc/#references

Просмотреть файл

@ -106,12 +106,6 @@ var redirects = map[string]string{
"/issues": "https://github.com/golang/go/issues",
"/design": "https://go.googlesource.com/proposal/+/master/design",
// In Go 1.2 the references page is part of /doc/.
"/ref": "/doc/#references",
// This next rule clobbers /ref/spec and /ref/mem.
// TODO(adg): figure out what to do here, if anything.
// "/ref/": "/doc/#references",
// Be nice to people who are looking in the wrong place.
"/pkg/C/": "/cmd/cgo/",
"/doc/mem": "/ref/mem",

Просмотреть файл

@ -22,7 +22,6 @@ func errorResult(status int) redirectResult {
func TestRedirects(t *testing.T) {
var tests = map[string]redirectResult{
"/build": {301, "https://build.golang.org"},
"/ref": {301, "/doc/#references"},
"/doc/mem": {301, "/ref/mem"},
"/doc/spec": {301, "/ref/spec"},
"/foo": errorResult(404),