Lister object

objects

The lister object is an array-like object designed for storing and processing lists of pages.

It is available in the template variable list:

<ul class="menu">
  {% for item in list.getNearFiles("/blog/index.html") %}
  <li><a href="{{ item.file.path }}">{{ item.meta.title }}</a></li>
  {% endfor %}
</ul>

Fields and methods

tags ( )
Parameters: none
Returns a list of tags sorted by title
sortByMeta ( meta_name, as_number, desc )
Returns a copy of Lister sorted by the specified metadata
Parameter Type Purpose
meta_name string Metadata field
as_number boolean Numeric sorting
desc boolean Sort in descending order
getByPath ( path )
Returns a page by site path
Parameter Type Purpose
path string Path
getByMeta ( meta_name, meta_value )
Returns a page by metadata name/value pair
Parameter Type Purpose
meta_name string Metadata field
meta_value string|number Value
excludeByMeta ( meta_name, meta_value )
Excludes pages by metadata name/value pair, returns a new Lister
Parameter Type Purpose
meta_name string Metadata field
meta_value string|number Value
getAllByMeta ( meta_name, meta_value )
Returns all pages with the specified metadata value
Parameter Type Purpose
meta_name string Metadata field
meta_value string|number Value
getAllWithMeta ( meta_name )
Returns all pages containing the specified metadata
Parameter Type Purpose
meta_name string Metadata field
getAllFiles ( page )
Returns all pages under the given path (excluding tags, virtual and index pages)
Parameter Type Purpose
page string Path or page object
getAllDirs ( page )
Returns all index pages (directories) under the given path
Parameter Type Purpose
page string Path or page object
getNearFiles ( page )
Returns all pages in the same directory as the specified path
Parameter Type Purpose
page string Path or page object
getNearDirs ( page )
Returns all index pages (directories) in the directory of the specified path
Parameter Type Purpose
page string Path or page object
getParent ( page )
Returns the nearest index file up the directory tree
Parameter Type Purpose
page string Path or page object
getBreadcrumbs ( page, skip )
Returns breadcrumbs, directories without index files are skipped. The second parameter defines how many directories to skip
Parameter Type Purpose
page string Path or page object
skip number Number of directories to skip
forEach ( fn )
Standard forEach()
Parameter Type Purpose
fn function Function to execute for each element
map ( fn )
Standard map()
Parameter Type Purpose
fn function Function to execute for each element
slice ( start, end )
Standard slice() (returns an array)
Parameter Type Purpose
start number Start index
end number End index
sort ( fn )
Returns a sorted copy.
Parameter Type Purpose
fn function Sorting function
length
Parameters: none
Length field - number of elements.
replace ( array )
Replaces the current list with a new one and returns a new Lister
Parameter Type Purpose
array array Array of pages
append ( array )
Appends a list to the current Lister, returns new Lister
Parameter Type Purpose
array array Array of pages
unwrap ( )
Parameters: none
Returns the original array of pages