pagination

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderSimpleLiquid

func RenderSimpleLiquid(tmpl string, varName string, item interface{}) string

RenderSimpleLiquid renders a simple Liquid-style template by replacing {{ varName.field }} with the corresponding value from the item.

func ResolveDataSource

func ResolveDataSource(ref string, siteData map[string]interface{}, collections map[string]interface{}) ([]interface{}, error)

ResolveDataSource looks up a data source reference (e.g., "site.data.team", "collections.articles") and returns the resolved data slice.

Types

type PaginationContext

type PaginationContext struct {
	PageNumber   int
	TotalPages   int
	PreviousPage string
	NextPage     string
	First        string
	Last         string
	Items        []interface{}
}

PaginationContext holds pagination state for a single paginated page.

func Paginate

func Paginate(data []interface{}, perPage int, basePath string, pathSegment string) ([]PaginationContext, []string, error)

Paginate splits data into pages and returns pagination contexts and output paths.

func PaginateWithTemplatePermalink(data []interface{}, permalinkTemplate string, as string, renderer TemplateRenderer) ([]PaginationContext, []string, error)

PaginateWithTemplatePermalink generates one virtual page per data item, using the provided renderer callback to resolve the permalink template. This works with any template engine (Liquid, Go templates, etc.).

type TemplateRenderer

type TemplateRenderer func(source string, ctx map[string]interface{}) (string, error)

TemplateRenderer renders a template string with the given context variables.

Jump to

Keyboard shortcuts

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