Home Manual Reference Source Test Repository
import CollectionBase from 'reptar/lib/collection/base.js'
public class | source

CollectionBase

Static Method Summary

Static Public Methods
public static

sortFiles(files: Array<File>, sortConfig: Object, dateFormat: string): Array<file>

Sorts files according to a sort config object.

Constructor Summary

Public Constructor
public

constructor(name: string, collectionConfig: Object, config: Config, renderer: Renderer)

Create a Collection instance.

Member Summary

Public Members
public

Data accesible to templates.

public

Unique ID of this Collection, currently its given name.

public

Metadata attribute to use to find which items are within the collection.

public

The collection name.

public

Size of each CollectionPage.

public

Array of CollectionPage objects.

public

Path where items belong within the collection.

public

Permalink information.

public

Sorting configuration.

public

What template to use when rendering a CollectionPage.

Protected Members
protected
protected

Method Summary

Public Methods
public

createPage(index: number, pageIdArg: string): CollectionPage

Create a CollectionPage instance.

public

Whether a File is filtered by the configured filters.

public

populate(files: Object<string, Files>, collections: Object<string, CollectionBase>): CollectionBase

Populate the Collection's files via file system path or metadata attribute.

public

write(siteData: Object): Promise

Writes every page in this collection.

Static Public Methods

public static sortFiles(files: Array<File>, sortConfig: Object, dateFormat: string): Array<file> source

Sorts files according to a sort config object.

Params:

NameTypeAttributeDescription
files Array<File>

Array of File objects.

sortConfig Object

Sort config object.

dateFormat string

Optional. File date format from config.

Return:

Array<file>

Sorted files.

Public Constructors

public constructor(name: string, collectionConfig: Object, config: Config, renderer: Renderer) source

Create a Collection instance.

Params:

NameTypeAttributeDescription
name string

The name of the collection.

collectionConfig Object

Config object from config file.

config Config

Config instance.

renderer Renderer

Renderer instance.

Public Members

public data: Object source

Data accesible to templates.

public id: string source

Unique ID of this Collection, currently its given name.

public metadata: string source

Metadata attribute to use to find which items are within the collection.

public name: string source

The collection name. Must be unique.

public pageSize: number source

Size of each CollectionPage.

public pages: Array<CollectionPage> source

Array of CollectionPage objects.

public path: string source

Path where items belong within the collection.

Permalink information.

public sort: Object source

Sorting configuration.

public template: string source

What template to use when rendering a CollectionPage.

Protected Members

protected _config: Config source

protected _renderer: Renderer source

Public Methods

public createPage(index: number, pageIdArg: string): CollectionPage source

Create a CollectionPage instance.

Params:

NameTypeAttributeDescription
index number

Index of the page.

pageIdArg string

Optional custom ID for a CollectionPage.

Return:

CollectionPage

CollectionPage instance.

public isFiltered(file: File): boolean source

Whether a File is filtered by the configured filters.

Params:

NameTypeAttributeDescription
file File

File object.

Return:

boolean

Whether this file should be filtered out.

public populate(files: Object<string, Files>, collections: Object<string, CollectionBase>): CollectionBase source

Populate the Collection's files via file system path or metadata attribute.

Params:

NameTypeAttributeDescription
files Object<string, Files>

All Files.

collections Object<string, CollectionBase>

Object of all collections.

Return:

CollectionBase

public write(siteData: Object): Promise source

Writes every page in this collection.

Params:

NameTypeAttributeDescription
siteData Object

Site wide data that is shared on all rendered pages.

Return:

Promise