segmentio/metalsmith-permalinks — pull request #26 by lygaret (2014-11-19 04:37:40+00:00)
Title: LinkSets

## What?

In my build, I'd like to have different permalink patterns per collection. I'm currently doing it by combining PR #24 with multiple invocations of the plugin, effectively giving me "scoped" permalink patterns. While it's working (for the most part), it's clumsy.

This PR is a proposal for a new feature to introduce scoped sets of options, using the passed in options as default, matching on arbitrary metadata. The idea is that, e.g., a `blogposts` collection could have a permalink pattern like `:date/:title`, while a `pages` collection could have a different pattern, such as `pages/:title`.

Backwards compatibility (meaning the tests pass :icecream:) is maintained by making the original options objects act as defaults for each linkset, and also as the default linkset itself.

## How it would work

```js
.use(permalinks({
// original options would act as the keys of a `default` linkset,
pattern: ':title',
date: 'YYYY',

// each linkset defines a match, and any other desired option
linksets: [{
match: { collection: 'blogposts' },
pattern: 'blog/:date/:title',
date: 'mmddyy'
},{
match: { collection: 'pages' },
pattern: 'pages/:title'
}]
}));

```

Eventually, I think a bunch of more sophisticated matchers et al. would be awesome, and a bunch more tests, but I wanted to make sure I wasn't running down a path that you'd disagree with too strongly.