navigation

package
v0.104.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Overview

Copyright 2021 The Hugo Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var NopPageMenus = new(nopPageMenus)

Functions

This section is empty.

Types

type Menu []*MenuEntry

Menu is a collection of menu entries.

func (m Menu) Add(me *MenuEntry) Menu

This is for internal use only.

func (m Menu) ByName() Menu

ByName sorts the menu by the name defined in the menu configuration.

func (m Menu) ByWeight() Menu

ByWeight sorts the menu by the weight defined in the menu configuration.

func (m Menu) Clone() Menu

Clone clones the menu entries. This is for internal use only.

func (m Menu) Limit(n int) Menu

Limit limits the returned menu to n entries.

func (m Menu) Reverse() Menu

Reverse reverses the order of the menu entries.

func (m Menu) Sort() Menu

Sort sorts the menu by weight, name and then by identifier.

type MenuEntry struct {
	// The URL value from front matter / config.
	ConfiguredURL string

	// The Page connected to this menu entry.
	Page Page

	// The path to the page, only relevant for menus defined in site config.
	PageRef string

	// The name of the menu entry.
	Name string

	// The menu containing this menu entry.
	Menu string

	// Used to identify this menu entry.
	Identifier string

	// If set, will be rendered before this menu entry.
	Pre template.HTML

	// If set, will be rendered after this menu entry.
	Post template.HTML

	// The weight of this menu entry, used for sorting.
	// Set to a non-zero value, negative or positive.
	Weight int

	// Identifier of the parent menu entry.
	Parent string

	// Child entries.
	Children Menu

	// User defined params.
	Params maps.Params
	// contains filtered or unexported fields
}

MenuEntry represents a menu item defined in either Page front matter or in the site config.

func (m *MenuEntry) HasChildren() bool

HasChildren returns whether this menu item has any children.

func (m *MenuEntry) IsEqual(inme *MenuEntry) bool

IsEqual returns whether the two menu entries represents the same menu entry.

func (m *MenuEntry) IsSameResource(inme *MenuEntry) bool

IsSameResource returns whether the two menu entries points to the same resource (URL).

func (m *MenuEntry) KeyName() string

KeyName returns the key used to identify this menu entry.

func (m *MenuEntry) MarshallMap(ime map[string]any) error

For internal use.

func (m *MenuEntry) Title() string
func (m *MenuEntry) URL() string
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 map[string]Menu

Menus is a dictionary of menus.

type MenusGetter interface {
	Menus() Menus
}

type Page

type Page interface {
	LinkTitle() string
	RelPermalink() string
	Path() string
	Section() string
	Weight() int
	IsPage() bool
	IsSection() bool
	IsAncestor(other any) (bool, error)
	Params() maps.Params
}

A narrow version of page.Page.

type PageMenus map[string]*MenuEntry

PageMenus is a dictionary of menus defined in the Pages.

func PageMenusFromPage(p Page) (PageMenus, error)
type PageMenusGetter interface {
	Menus() PageMenus
}
type PageMenusProvider interface {
	PageMenusGetter
	MenuQueryProvider
}

Jump to

Keyboard shortcuts

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