Closed rstacruz closed 2 years ago
👍 On this.
I've spent some time on this issue. In my case (using collection:
in frontmatter, collections gets populated automatically.
My solution is as follows:
app = metalsmith()
.use((files, ms, done) => {
const metadata = ms.metadata()
const { collections } = metadata
if (collections) {
Object.keys(collections).forEach((k) => {
metadata[k] = [];
});
}
done()
})
.use(collections())
.build(done => ...)
.build(done => ...)
Closing as this is a duplicate of #27
The plugin isn't idempotent, running it twice will screw up the metadata.
The workaround is to create a middleware that clears up metadata: