Home Manual Reference Source Test Repository
import MetadataCollection from 'reptar/lib/collection/type/metadata.js'
public class | source

MetadataCollection

Extends:

CollectionBase → MetadataCollection

A collection that derives its content from a match in a files yaml frontmatter data.

Constructor Summary

Public Constructor
public

constructor(name: *, collectionConfig: *, config: *, renderer: *)

Member Summary

Public Members
public

Object which holds a mapping of metadata value to the files that contain the metadata property.

public

pages: *[]

Method Summary

Public Methods
public

addFile(file: File): boolean

Add a file to the collection.

public

populate(files: Object<string, Files>): Collection

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

Inherited Summary

From class CollectionBase
public static

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

Sorts files according to a sort config object.

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
protected
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.

Public Constructors

public constructor(name: *, collectionConfig: *, config: *, renderer: *) source

Create a Collection instance.

Override:

CollectionBase#constructor

Params:

NameTypeAttributeDescription
name *
collectionConfig *
config *
renderer *

Public Members

public metadataFiles: Object<string, Array<File>> source

Object which holds a mapping of metadata value to the files that contain the metadata property. For example with metadata of 'tags' you'd have: { 'tag-name': [file, file], 'other-tag': [file, file] }

public pages: *[] source

Array of CollectionPage objects.

Override:

CollectionBase#pages

Public Methods

public addFile(file: File): boolean source

Add a file to the collection.

Params:

NameTypeAttributeDescription
file File

File object.

Return:

boolean

True if the file was added to the collection.

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

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

Override:

CollectionBase#populate

Params:

NameTypeAttributeDescription
files Object<string, Files>

Object of files.

Return:

Collection