module:metalsmith-grouped-page

metalsmith-grouped-page

module.exports(options) ⇒ function

Metalsmith plugin. Group files into a collection and create a new metalsmith file that has the collection in its metadata.

Kind: Exported function
Returns: function - metalsmith().use(callback) callback

Param Type Description
options Object
options.path String stringified deep path to the group key. See docs for lodash.get
[ options.metakey ] String key under which the grouped files are added as metalsmith.metadata().groupedPages.metakey = alphabetized array of groupedPages (so [ 0 ] is tag starting with "a")
[ options.metadata ] Object additional metadata to add to the grouped page in initialization of the group (you can use transform to do this too)
[ options.slugFunction ] function function to slugify the group name
[ options.transform ] function transformation to apply to groups before adding to files/metadata objects

module.exports~getGroup(groupName) ⇒ Object

Given a groupname, return existing group or create a new group and file object for that group.

Kind: inner method of module.exports
Returns: Object - metalsmith file object with group data

Param Type
groupName String

module.exports~groupByString(files, file, value)

Put file into group given the name of the group

Kind: inner method of module.exports

Param Type Description
files Object metalsmith files object
file Object current file to put into a group
value String

Example

tags: abc, def not implemented

module.exports~groupByArray(files, file, values)

Put file into groups given an array of groups file should go into

Kind: inner method of module.exports

Param Type Description
files Object metalsmith files object
file Object current file to put into a group
values Array. < String > to group file by

Example

tags:
   - sometag
   - anothertag

groupByArray~groupByValue(value)

groupByValue

Kind: inner method of groupByArray

Param Type Description
value String e.g. tag to group file by

module.exports~groupFiles(files, metalsmith, done)

Metalsmith files iterator

Kind: inner method of module.exports

Param Type Description
files Object keyed by filename from metalsmith
metalsmith Object
done function

groupFiles~group(file) ⇒ Void

Given a filepath, put the corresponding file in a group

Kind: inner method of groupFiles

Param Type Description
file String key in files

groupFiles~applyTransform(transform)

Apply any transformations to groups, e.g. prefixing path (groups[path]) or adding additional metadata

Kind: inner method of groupFiles

Param Type
transform function