Skip to content

lowmess/metalsmith-auto-collections

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

metalsmith-auto-collections

Automatically use metalsmith-collections. The collection name is equal to the parent directory of each file.

Installation

npm install metalsmith-auto-collections [-D]

Usage

const Metalsmith = require('metalsmith')
const collect = require('metalsmith-auto-collections')

const ms = Metalsmith(__dirname)

// add all files to a collection
ms.use(collect())

// use globs to only set certain files to a collection
ms.use(
  collect({
    pattern: ['**/*.md', '!*.md'],
  })
)

// pass settings to `metalsmith-collections`
ms.use(
  collect({
    pattern: '**/*.md',
    settings: {
      sortBy: 'date',
      reverse: true,
    },
  })
)

// pass collections to metalsmith-collections (for manual collections)
ms.use(
  collect({
    collections: {
      navigation: {
        sortBy: 'ordering',
      },
    },
  })
)

To see the available options, see the metalsmith-collections repo.