package navigation
import "github.com/gohugoio/hugo/navigation"
Package navigation provides the menu functionality.
Index ¶
- Variables
- func DecodeConfig(in any) (*config.ConfigNamespace[map[string]MenuConfig, Menus], error)
- func SetPageValues(m *MenuEntry, p Page)
- type Menu
- func (m Menu) Add(me *MenuEntry) Menu
- func (m Menu) ByName() Menu
- func (m Menu) ByWeight() Menu
- func (m Menu) Clone() Menu
- func (m Menu) Limit(n int) Menu
- func (m Menu) Reverse() Menu
- func (m Menu) Sort() Menu
- type MenuConfig
- type MenuEntry
- func (m *MenuEntry) HasChildren() bool
- func (m *MenuEntry) KeyName() string
- func (m *MenuEntry) URL() string
- type MenuQueryProvider
- type Menus
- type MenusGetter
- type Page
- type PageMenus
- type PageMenusGetter
- type PageMenusProvider
Variables ¶
var NopPageMenus = new(nopPageMenus)
Functions ¶
func DecodeConfig ¶
func DecodeConfig(in any) (*config.ConfigNamespace[map[string]MenuConfig, Menus], error)
func SetPageValues ¶
SetPageValues sets the Page and URL values for this menu entry.
Types ¶
type Menu ¶
type Menu []*MenuEntry
Menu is a collection of menu entries.
func (Menu) Add ¶
This is for internal use only.
func (Menu) ByName ¶
ByName sorts the menu by the name defined in the menu configuration.
func (Menu) ByWeight ¶
ByWeight sorts the menu by the weight defined in the menu configuration.
func (Menu) Clone ¶
Clone clones the menu entries. This is for internal use only.
func (Menu) Limit ¶
Limit limits the returned menu to n entries.
func (Menu) Reverse ¶
Reverse reverses the order of the menu entries.
func (Menu) Sort ¶
Sort sorts the menu by weight, name and then by identifier.
type MenuConfig ¶
type MenuConfig struct { Identifier string Parent string Name string Pre template.HTML Post template.HTML URL string PageRef string Weight int Title string // User defined params. Params maps.Params }
MenuConfig holds the configuration for a menu.
type MenuEntry ¶
type MenuEntry struct { // The menu entry configuration. MenuConfig // The menu containing this menu entry. Menu string // The URL value from front matter / config. ConfiguredURL string // The Page connected to this menu entry. Page Page // Child entries. Children Menu }
MenuEntry represents a menu item defined in either Page front matter or in the site config.
func (*MenuEntry) HasChildren ¶
HasChildren returns whether this menu item has any children.
func (*MenuEntry) KeyName ¶
KeyName returns the key used to identify this menu entry.
func (*MenuEntry) URL ¶
type MenuQueryProvider ¶
type MenuQueryProvider interface { HasMenuCurrent(menuID string, me *MenuEntry) bool IsMenuCurrent(menuID string, inme *MenuEntry) bool }
func NewMenuQueryProvider ¶
func NewMenuQueryProvider( pagem PageMenusGetter, sitem MenusGetter, p Page, ) MenuQueryProvider
type Menus ¶
Menus is a dictionary of menus.
type MenusGetter ¶
type MenusGetter interface { Menus() Menus }
type Page ¶
type Page interface { LinkTitle() string Title() string RelPermalink() string Path() string Section() string Weight() int IsPage() bool IsSection() bool IsAncestor(other any) bool Params() maps.Params }
A narrow version of page.Page.
type PageMenus ¶
PageMenus is a dictionary of menus defined in the Pages.
func PageMenusFromPage ¶
type PageMenusGetter ¶
type PageMenusGetter interface { Menus() PageMenus }
type PageMenusProvider ¶
type PageMenusProvider interface { PageMenusGetter MenuQueryProvider }
Source Files ¶
menu.go menu_cache.go pagemenus.go
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 13 hours ago –
Tools for package owners.