nav

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Activate

func Activate(items []*Nav, r *http.Request)

Activate checks each nav item in the tree of items passed to see if the url exactly matches the current url path and sets the .Active flag when it does

Used to help nav display

func Flat

func Flat(items []*Nav, r *http.Request) (flatMap map[string]*Nav)

Flat creates a flatMap from the original items passed. It marks any nav item whose url is contained within the current request url path as being active

Types

type Nav struct {
	Name        string            `json:"name"`
	Uri         string            `json:"uri"`
	Template    string            `json:"template"`
	IsHeader    bool              `json:"is_header"`
	DataSources map[string]string `json:"data_sources"`
	Navigation  []*Nav            `json:"navigation"`
	Active      bool              `json:"-"`
	Registered  bool              `json:"-"`
}

func ForTemplate

func ForTemplate(templateName string, navs []*Nav) (found []*Nav)

ForTemplate creates a list of all nav items from the list passed whose template matches the templateName

func Level

func Level(items []*Nav, r *http.Request) (nav map[string]*Nav, active *Nav)

Level checks only the current level (does not recurse) of the nav items passed to see if any "active" (url contains current url) If active is found then also run the activate check on the subitems

func New

func New(content []byte) (navList []*Nav)
func (n *Nav) ClassName() string
func (n *Nav) InUrlPath(url string) bool
func (n *Nav) Matches(url string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL