helpers

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMenuKeys

func AddMenuKeys(items []navinternal.MenuItem, dest map[string]bool)

AddMenuKeys records canonical keys for a slice of MenuItems into the provided set.

func BuildMenuTree

func BuildMenuTree(items []navinternal.MenuItem) []navinternal.MenuItem

BuildMenuTree reconstructs a hierarchy from a flat slice using ParentID metadata.

func CanonicalMenuKeys

func CanonicalMenuKeys(item navinternal.MenuItem) []string

CanonicalMenuKeys returns stable keys used to dedupe menu items across persistent backends.

func DedupeMenuItems

func DedupeMenuItems(items []navinternal.MenuItem) []navinternal.MenuItem

DedupeMenuItems filters a slice of MenuItems using canonical keys.

func ExtractTargetKey

func ExtractTargetKey(target map[string]any) string

ExtractTargetKey pulls a stable key from a target map.

func HasAnyKey

func HasAnyKey(set map[string]bool, keys []string) bool

HasAnyKey checks if any of the provided keys are present in the set.

func MapMenuIDs

func MapMenuIDs(item navinternal.MenuItem) navinternal.MenuItem

MapMenuIDs normalizes ID and ParentID values to canonical menu item paths.

func MenuHasTarget(items []navinternal.MenuItem, key string, menuPath string) bool

MenuHasTarget checks whether a menu tree contains a target.

func MenuUUIDFromSlug(slug string) string

MenuUUIDFromSlug derives a deterministic UUID string from a menu slug/name.

func NavigationHasTarget(items []navinternal.NavigationItem, key string, menuPath string) bool

NavigationHasTarget checks whether a navigation tree contains a target.

func NormalizeMenuItem

func NormalizeMenuItem(item navinternal.MenuItem, menuCode string) navinternal.MenuItem

NormalizeMenuItem ensures menu code is set and derives an ID when missing.

func NormalizeMenuSlug

func NormalizeMenuSlug(raw string) string

NormalizeMenuSlug converts an arbitrary name/code into a normalized slug.

func TargetMatches

func TargetMatches(target map[string]any, key string, menuPath string) bool

TargetMatches returns true when a target map matches key or path.

Types

type Translator

type Translator interface {
	Translate(locale, key string, args ...any) (string, error)
}

Translator resolves i18n keys into localized strings.

Jump to

Keyboard shortcuts

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