blob: 8de64a88d1497052edd69bd3c8a2050fc36bbb1a [file] [log] [blame]
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package frontend
import (
// searchTip represents a snippet of text on the homepage demonstrating
// how to effectively use search.
type searchTip struct {
Text string
Example1 string
Example2 string
var searchTips = []searchTip{
"Search for a package, for example",
"Search for a symbol, for example",
"Search for symbols within a package using the # filter. For example",
" #error",
"#reader io",
// Homepage contains fields used in rendering the homepage template.
type homepage struct {
// TipIndex is the index of the initial search tip to render.
TipIndex int
// SearchTips is a collection of search tips to show on the homepage.
SearchTips []searchTip
func (s *Server) serveHomepage(ctx context.Context, w http.ResponseWriter, r *http.Request) {
s.servePage(ctx, w, "homepage", homepage{
basePage: s.newBasePage(r, "Go Packages"),
SearchTips: searchTips,
TipIndex: rand.Intn(len(searchTips)),