1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-30 14:21:00 +02:00
seaweedfs/weed/server/filer_ui/breadcrumb.go
2019-12-11 23:09:01 -08:00

29 lines
480 B
Go

package master_ui
import (
"path/filepath"
"strings"
)
type Breadcrumb struct {
Name string
Link string
}
func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
parts := strings.Split(fullpath, "/")
for i := 0; i < len(parts); i++ {
crumb := Breadcrumb{
Name: parts[i] + " /",
Link: "/" + filepath.ToSlash(filepath.Join(parts[0:i+1]...)),
}
if !strings.HasSuffix(crumb.Link, "/") {
crumb.Link += "/"
}
crumbs = append(crumbs, crumb)
}
return
}