Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkSets #26

Merged
merged 2 commits into from
Dec 25, 2015
Merged

LinkSets #26

merged 2 commits into from
Dec 25, 2015

Conversation

lygaret
Copy link
Contributor

@lygaret lygaret commented Nov 19, 2014

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 🍦) 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

  .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.

@sebastienbarre
Copy link

Nice, though actually I think you had nailed it in PR #24, multiple invocations of the plugin seem more elegant to me than multiple linksets co-existing with the original options. Thanks!

@ninjasort
Copy link

@lygaret This looks good! I'm having the same issue (currently using metalsmith-branch). Would love to see this merged!

lambtron added a commit that referenced this pull request Dec 25, 2015
@lambtron lambtron merged commit 4efdc74 into metalsmith:master Dec 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants