metalsmith-relations

1.0.0 • Public • Published

metalsmith-relations

A Metalsmith plugin that computes related documents for each document in a collection.

Dependencies NPM Version License

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 }
});

Readme

Keywords

none

Package Sidebar

Install

npm i metalsmith-relations

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • tjpeden