navigation

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package navigation builds sidebar nav trees, breadcrumbs, and prev/next links for docs-layout collections.

Sidebar strategy dispatch moved from internal/sidebar.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBreadcrumbs

func BuildBreadcrumbs(page *engine.Page, collection *engine.Collection) []engine.BreadcrumbItem

BuildBreadcrumbs constructs a breadcrumb trail for a docs-layout page. The trail starts with the collection root and ends with the current page.

func BuildBreadcrumbsTabbed

func BuildBreadcrumbsTabbed(page *engine.Page, col *engine.Collection, tab *engine.DocsTab) []engine.BreadcrumbItem

BuildBreadcrumbsTabbed constructs breadcrumbs for a tabbed docs page. Adds the tab as a level between the collection root and section chain.

func BuildBreadcrumbsVersioned

func BuildBreadcrumbsVersioned(page *engine.Page, col *engine.Collection) []engine.BreadcrumbItem

BuildBreadcrumbsVersioned constructs breadcrumbs for a versioned docs page. Inserts the version label between the collection root and the section chain.

func BuildGlobalNav

func BuildGlobalNav(site *engine.SiteContext, currentCollection *engine.Collection, headerLinks []config.NavLink) *engine.GlobalNav

BuildGlobalNav builds the top-level site navigation from collections and optional header links from the site config. Collection items are sorted alphabetically; header links are appended after collection items.

func BuildNavTree

func BuildNavTree(collection *engine.Collection) *engine.NavTree

BuildNavTree constructs a NavTree from a collection's section tree. For docs-layout collections, this produces the sidebar navigation. The tree respects transparent sections (hoisted), non-rendering sections (group label only), hidden pages, and weight-based sorting.

func BuildNavTreeFromYAML

func BuildNavTreeFromYAML(yamlPath string, collection *engine.Collection) (*engine.NavTree, error)

BuildNavTreeFromYAML parses a nav.yaml file and constructs a NavTree. When nav.yaml exists, it completely replaces auto-generated navigation.

func MarkActive

func MarkActive(tree *engine.NavTree, currentPage *engine.Page) *engine.NavTree

MarkActive deep-clones the NavTree and marks the active node and its ancestor chain for the current page. The clone ensures the shared collection-level NavTree is not mutated during parallel rendering.

func WirePrevNextFromTree

func WirePrevNextFromTree(tree *engine.NavTree)

WirePrevNextFromTree rewires Page.PrevPage/NextPage based on the nav tree's flattened DFS order. This replaces simple sort-order prev/next for docs-layout collections, enabling cross-section navigation.

Types

type DefaultSidebarStrategy

type DefaultSidebarStrategy struct{}

DefaultSidebarStrategy returns no sidebar for default-layout collections.

func (*DefaultSidebarStrategy) Build

func (s *DefaultSidebarStrategy) Build(page *engine.Page, collection *engine.Collection) *SidebarResult

type DocsSidebarStrategy

type DocsSidebarStrategy struct{}

DocsSidebarStrategy returns the collection's pre-built NavTree for docs-layout.

func (*DocsSidebarStrategy) Build

func (s *DocsSidebarStrategy) Build(page *engine.Page, collection *engine.Collection) *SidebarResult

type SidebarResult

type SidebarResult struct {
	Enabled bool
	Tree    *engine.NavTree
	Type    string // "nav", "widget", "none"
}

SidebarResult holds the output of a sidebar strategy build.

type SidebarStrategy

type SidebarStrategy interface {
	Build(page *engine.Page, collection *engine.Collection) *SidebarResult
}

SidebarStrategy determines sidebar content for a given page/collection.

func GetStrategy

func GetStrategy(layout engine.LayoutType) SidebarStrategy

GetStrategy returns the appropriate sidebar strategy for a layout type.

Jump to

Keyboard shortcuts

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