goldsmith-components: github.com/FooSoft/goldsmith-components/plugins/pager Index | Files

package pager

import "github.com/FooSoft/goldsmith-components/plugins/pager"

Package pager splits arrays of metadata into standalone pages. The plugin is initialized with a lister callback which is used to segment a slice of metadata contained within the provided file. While any large set of metadata can be split into segments, this plugin is particularly useful when working with the "collection" for paging blog entries, photos, etc.

Index

Package Files

pager.go

type Index Uses

type Index struct {
    AllPages []Page
    CurrPage *Page
    Paged    bool
}

Index contains paging information for the current file.

type Lister Uses

type Lister func(file *goldsmith.File) interface{}

Lister callback function is used to return a metadata slice which should be paged across several files.

type Namer Uses

type Namer func(path string, index int) string

Namer callback function builds paths for file pages based on the original file path and page index.

type Page Uses

type Page struct {
    Index int
    Items interface{}
    File  *goldsmith.File

    Next *Page
    Prev *Page
}

Page represents information about a given metadata segment.

type Pager Uses

type Pager struct {
    // contains filtered or unexported fields
}

Pager chainable context.

func New Uses

func New(lister Lister) *Pager

New creates a new instance of the Pager plugin.

func (*Pager) EnableKey Uses

func (plugin *Pager) EnableKey(key string) *Pager

EnableKey sets the metadata key used to determine if the current file should be paged (default: false).

func (*Pager) Finalize Uses

func (plugin *Pager) Finalize(ctx *goldsmith.Context) error

func (*Pager) InheritedKeys Uses

func (p *Pager) InheritedKeys(keys ...string) *Pager

InheritedKeys sets which metadata keys should be copied to generated pages from the original file (default: []). When no keys are provided, all metadata is copied from the original file to generated pages.

func (*Pager) Initialize Uses

func (*Pager) Initialize(context *goldsmith.Context) (goldsmith.Filter, error)

func (*Pager) ItemsPerPage Uses

func (plugin *Pager) ItemsPerPage(limit int) *Pager

ItemsPerPage sets the maximum number of items which can be included on a single page (default: 10).

func (*Pager) Name Uses

func (*Pager) Name() string

func (*Pager) Namer Uses

func (plugin *Pager) Namer(namer Namer) *Pager

Namer sets the callback used to build paths for file pages. Default naming inserts page number between file name and extension, for example "file.html" becomes "file-2.html".

func (*Pager) PagerKey Uses

func (plugin *Pager) PagerKey(key string) *Pager

PagerKey sets the metadata key used to store paging information for each file (default: "Pager").

func (*Pager) Process Uses

func (plugin *Pager) Process(context *goldsmith.Context, inputFile *goldsmith.File) error

Package pager imports 9 packages (graph). Updated 2019-04-08. Refresh now. Tools for package owners.