metalsmith-relations
v1.0.0
Published
A Metalsmith plugin that computes related documents for each document in a collection
Downloads
4
Readme
metalsmith-relations
A Metalsmith plugin that computes related documents for each document in a collection.
This project is similar to metalsmith-related, but favors property matching over globbing. This is the same approach that metalsmith-permalinks uses, which is typically dependent metalsmith-collections. There is no real difference other than that. It's written in TypeScript, but the algorithm and supporting library, natural, are the same.
Use
$ npm install metalsmith-relations
Then in your build script:
const Metalsmith = require('metalsmith');
const markdown = require('metalsmith-markdown');
const relations = require('metalsmith-relations');
const collections = require('metalsmith-collections');
Metalsmith(__dirname)
.use(collections())
.use(relations({
match: {
collection: 'posts' // or whatever
},
terms: 5,
max: 5,
threshold: 0,
text: document => String(document.content)
}))
.use(markdown())
.build((error, files) => {
if(error) { throw error }
});