nav

package
v1.10.0-sp2242.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

func Flattern added in v1.9.0

func Flattern(items []*Nav) (flatMap map[string]*Nav)

func Level

func Level(items []*Nav, r *http.Request) (nav map[string]*Nav, activeSection *Nav, activePage *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

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 Activate

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

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 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 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