You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
376 B

7 years ago
  1. package master_ui
  2. import (
  3. "path/filepath"
  4. "strings"
  5. )
  6. type Breadcrumb struct {
  7. Name string
  8. Link string
  9. }
  10. func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
  11. parts := strings.Split(fullpath, "/")
  12. for i := 0; i < len(parts); i++ {
  13. crumbs = append(crumbs, Breadcrumb{
  14. Name: parts[i] + "/",
  15. Link: "/" + filepath.Join(parts[0:i+1]...),
  16. })
  17. }
  18. return
  19. }