Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/lowmess/metalsmith-auto-collections. Automatically use metalsmith-collections www.npmjs.com/package/metalsmith-auto-collections
metalsmith metalsmith-plugin
Something went wrong. Try again.
JavaScript 96%
4%
Commits 44
build(deps): bump minimist from 1.2.5 to 1.2.6
Signed-off-by: dependabot[bot] <support@github.com>
build(deps): bump glob-parent from 5.1.1 to 5.1.2
Signed-off-by: dependabot[bot] <support@github.com>
build(deps): bump ajv from 6.12.0 to 6.12.6
Signed-off-by: dependabot[bot] <support@github.com>
build(deps): bump path-parse from 1.0.6 to 1.0.7
Signed-off-by: dependabot[bot] <support@github.com>
README.md
DEPRECATED #
It is suggested you use the @metalsmith/collections plugin directly. While there is (at time of writing) no way to automatically generate collections by directory, doing so manually is simple:
metalsmith.use(collections({
blog: 'blog/*',
features: 'features/*',
})
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.