Copyright 2020 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 (
	

	
	
)
displayBreadcrumbs appends additional breadcrumb links for display to those for the given unit.
func ( *internal.UnitMeta,  string) breadcrumb {
	 := breadcrumbPath(.Path, .ModulePath, )
	if .ModulePath == stdlib.ModulePath && .Path != stdlib.ModulePath {
		.Links = append([]link{{Href: "/std", Body: "Standard library"}}, .Links...)
	}
	.Links = append([]link{{Href: "/", Body: "Discover Packages"}}, .Links...)
	return 
}

type breadcrumb struct {
	Links    []link
	Current  string
	CopyData string
}

type link struct {
	Href, Body string
}
breadcrumbPath builds HTML that displays pkgPath as a sequence of links to its parents. pkgPath is a slash-separated path, and may be a package import path or a directory. modPath is the package's module path. This will be a prefix of pkgPath, except within the standard library. version is the version for the module, or LatestVersion. See TestBreadcrumbPath for examples.
func (, ,  string) breadcrumb {
	if  == stdlib.ModulePath {
		return breadcrumb{Current: "Standard library"}
Obtain successive prefixes of pkgPath, stopping at modPath, or for the stdlib, at the end.
	 := len() - 1
	if  == stdlib.ModulePath {
		 = 1
	}
	var  []string
	for  := ; len() >  && len(path.Dir()) < len();  = path.Dir() {
		 = append(, )
Construct the path elements of the result. They will be in reverse order of dirs. The first dir is the current page. If it is the only one, leave it as is. Otherwise, use its base. In neither case does it get a link.
	 := [0]
	if len() > 1 {
		 = path.Base()
	}
Make all the other parts into links.
	.Links = make([]link, len()-1)
	for  := 1;  < len(); ++ {
		 := "/" + []
		if  != internal.LatestVersion {
			 += "@" + linkVersion(, )
		}
		 := []
		if  != len()-1 {
			 = path.Base()
		}
		.Links[len(.Links)-] = link{, }
Add a "copy" button for the path.
	.CopyData = 
	return