Skip to content

Commit

Permalink
internal/frontend: change page title depending on users location
Browse files Browse the repository at this point in the history
Differentiate between home, search and package pages
in the sites title so users can tell them apart
easily when having multiple tabs open.

Fixes golang/go#41105

Change-Id: I9387d938b9bcbd2c610d2c38cb6cc13e661d8e04
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/275535
Reviewed-by: Julie Qiu <julie@golang.org>
Trust: Julie Qiu <julie@golang.org>
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
  • Loading branch information
Alex Hays authored and julieqiu committed Dec 8, 2020
1 parent f90f377 commit 68d251e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/frontend/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *Server) serveDetails(w http.ResponseWriter, r *http.Request, ds interna
return &serverError{status: http.StatusMethodNotAllowed}
}
if r.URL.Path == "/" {
s.staticPageHandler("index.tmpl", "")(w, r)
s.staticPageHandler("index.tmpl", "Home")(w, r)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/frontend/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (s *Server) serveSearch(w http.ResponseWriter, r *http.Request, ds internal
if err != nil {
return fmt.Errorf("fetchSearchPage(ctx, db, %q): %v", query, err)
}
page.basePage = s.newBasePage(r, query)
page.basePage = s.newBasePage(r, fmt.Sprintf("%s - Search Results", query))
s.servePage(ctx, w, "search.tmpl", page)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/frontend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *Server) Install(handle func(string, http.Handler), redisClient *redis.C
handle("/fetch/", fetchHandler)
handle("/play/", http.HandlerFunc(s.handlePlay))
handle("/search", searchHandler)
handle("/search-help", s.staticPageHandler("search_help.tmpl", "Search Help - go.dev"))
handle("/search-help", s.staticPageHandler("search_help.tmpl", "Search Help"))
handle("/license-policy", s.licensePolicyHandler())
handle("/about", http.RedirectHandler("https://go.dev/about", http.StatusFound))
handle("/badge/", http.HandlerFunc(s.badgeHandler))
Expand Down

0 comments on commit 68d251e

Please sign in to comment.