I'm generating a static site using Metalsmith's JavaScript API and metalsmith-collections
. I have a custom build script which assembles an array dogs
which I'd like to use to create a new collection.
const Metalsmith = require('metalsmith')
const collections = require('metalsmith-collections')
const layouts = require('metalsmith-layouts')
var dogs = [
{ name: 'Rover' },
{ name: 'Dog' },
{ name: 'Daisy' }
]
Metalsmith(__dirname)
.metadata({})
.source('./src')
.destination('./build')
.clean(true)
.use(layouts())
.use(collections({
dogs: {
// ?
}
})
.build((error) => {
if (error) throw error
console.log('All done!')
})
There are no files for dogs
; it's just an array which I've created myself. How do I instruct metalsmith-collections
to create a collection from the array?