Examples
Pipelines.Add("Posts",
ReadFiles("*.md"),
Markdown(),
WriteFiles("html")
);
Pipelines.Add("Archive",
ReadFiles("archive.cshtml"),
Paginate(10,
Documents("Posts")
),
Razor(),
WriteFiles(string.Format("archive-{0}.html", @doc["CurrentPage"]))
);
Usage
-
Paginate(int pageSize, IEnumerable<IModule> modules)
Partitions the result of the specified modules into the specified number of pages. The input documents to Paginate are used as the initial input documents to the specified modules.
pageSize
The number of documents on each page.
modules
The modules to execute to get the documents to page.
-
Paginate(int pageSize, params IModule[] modules)
Partitions the result of the specified modules into the specified number of pages. The input documents to Paginate are used as the initial input documents to the specified modules.
pageSize
The number of documents on each page.
modules
The modules to execute to get the documents to page.
Fluent Methods
Chain these methods together after the constructor to modify behavior.
-
SkipPages(int count)
Skips a specified number of pages before outputting pages.
count
The number of pages to skip.
-
TakePages(int count)
Only outputs a specific number of pages.
count
The number of pages to output.
-
Where(DocumentConfig predicate)
Limits the documents to be paged to those that satisfy the supplied predicate.
predicate
A delegate that should return a
bool
.
-
WithPageMetadata(string key, DocumentConfig metadata)
Adds the specified metadata to each page index document. This must be performed within the paginate module. If you attempt to process the page index documents from the paginate module after execution, it will "disconnect" metadata for those documents like
Wyam.Common.Meta.Keys.NextPage
since you're effectivly creating new documents and the ones those keys refer to will be outdated.key
The key of the metadata to add.
metadata
A delegate with the value for the metadata.
Output Metadata
The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.
-
Keys.CurrentPage
:System.Int32
The index of the current page (1 based).
-
Keys.HasNextPage
:System.Boolean
Whether there is another page after this one.
-
Keys.HasPreviousPage
:System.Boolean
Whether there is another page before this one.
-
Keys.NextPage
:Wyam.Common.Documents.IDocument
The next page.
-
Keys.PageDocuments
:IEnumerable<IDocument>
Contains all the documents for the current page.
-
Keys.PreviousPage
:Wyam.Common.Documents.IDocument
The previous page.
-
Keys.TotalItems
:System.Int32
The total number of items across all pages.
-
Keys.TotalPages
:System.Int32
The total number of pages.