init
This commit is contained in:
commit
fa6a4c650f
93 files changed
+6555
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package server
|
||||
|
||||
import "strings"
|
||||
|
||||
type Breadcrumb struct {
|
||||
Name string
|
||||
Path string
|
||||
}
|
||||
|
||||
func buildBreadcrumbs(
|
||||
path string,
|
||||
) []Breadcrumb {
|
||||
|
||||
path = cleanSemanticPath(path)
|
||||
|
||||
if path == "/" {
|
||||
return nil
|
||||
}
|
||||
|
||||
parts :=
|
||||
strings.Split(
|
||||
strings.Trim(path, "/"),
|
||||
"/",
|
||||
)
|
||||
|
||||
var out []Breadcrumb
|
||||
current := ""
|
||||
|
||||
for _, p := range parts {
|
||||
|
||||
current += "/" + p
|
||||
|
||||
out = append(out, Breadcrumb{
|
||||
Name: p,
|
||||
Path: current,
|
||||
})
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user