templates: Add a proper menu and navigation
This commit is contained in:
parent
0bb7f99fa3
commit
a00195be16
76 changed files with 336 additions and 233 deletions
36
internal/dis/component/menu.go
Normal file
36
internal/dis/component/menu.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package component
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Menuable is a component that provides a menu
|
||||
type Menuable interface {
|
||||
Component
|
||||
|
||||
Menu(r *http.Request) []MenuItem
|
||||
}
|
||||
type MenuItem struct {
|
||||
Title string
|
||||
Path template.URL
|
||||
Active bool
|
||||
|
||||
Priority MenuPriority // menu priority
|
||||
}
|
||||
|
||||
func MenuItemSort(a, b MenuItem) bool {
|
||||
return a.Priority < b.Priority
|
||||
}
|
||||
|
||||
type MenuPriority int
|
||||
|
||||
// Menu* indicates priorities of the menu
|
||||
const (
|
||||
MenuHome MenuPriority = iota
|
||||
MenuNews
|
||||
MenuResolver
|
||||
MenuUser
|
||||
MenuAdmin
|
||||
MenuAuth
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue