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.



    This section is empty.


    This section is empty.


    This section is empty.


    type Index

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

      Index contains paging information for the current file.

      type Lister

      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

        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

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

            Page represents information about a given metadata segment.

            type Pager

            type Pager struct {
            	// contains filtered or unexported fields

              Pager chainable context.

              func New

              func New(lister Lister) *Pager

                New creates a new instance of the Pager plugin.

                func (*Pager) EnableKey

                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

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

                  func (*Pager) InheritedKeys

                  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

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

                    func (*Pager) ItemsPerPage

                    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

                      func (*Pager) Name() string

                      func (*Pager) Namer

                      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

                        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

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

                          Source Files