permalinks icon indicating copy to clipboard operation
permalinks copied to clipboard

added support for option 'collection', which makes this plugin only effect files belonging to a collection, such as the ones created by 'metalsmith-collections'

Open sanx opened this issue 11 years ago • 7 comments
trafficstars

I think this is good alternative to setting "permalink: false" in the front matter for people who want to rely more on metalsmith-collections.

sanx avatar Nov 06 '14 01:11 sanx

+1, should be merged, very useful (if multiple invocations are supported, which PR #26 seem to confirm).

sebastienbarre avatar May 27 '15 23:05 sebastienbarre

:+1: wanted this kind of functionality for a while :wink: #17

misterdai avatar Sep 24 '15 13:09 misterdai

@ianstormtaylor any chance of this getting merged in?

misterdai avatar Sep 24 '15 14:09 misterdai

What if I want different permalink patterns for different collections, as well as a fallback for other collections? I tried this:

  .use(permalinks({
    collection: 'pages',
    pattern: ':title'
  }))
  .use(permalinks({
    collection: 'blog',
    pattern: ':date/:title'
  }))
  .use(permalinks({
    pattern: ':collection/:title'
  }))

That made it translate pages/about.html to about/index.html (as specified in invocation 1), but it subsequently applied the fallback and unexpectedly went back to pages/about/index.html.

Since the plugin instances are unaware of eachother, would it make sense to somehow flag files that have already been processed? Or perhaps the plugin should take an array of config blocks.

timdp avatar Nov 02 '15 13:11 timdp

@timdp it'd be cool if it'd add a unique key to flag if permalinks have been applied. I'd say .path but I think there are some other metalsmith plugins that also apply that. So if it threw in a ._permalinked = true to the file metadata, then if it's present then permalinks could skip over it.

Otherwise, an array approach would be nice and easily supported alongside the original object approach, to avoid breaking existing usages.

misterdai avatar Nov 02 '15 15:11 misterdai

The array is basically what #26 accomplishes though. That one's working like a treat for me.

timdp avatar Nov 02 '15 15:11 timdp

Thanks for the PR.

Could you resolve the conflicts or create a new PR based off master?

woodyrew avatar Jul 21 '18 13:07 woodyrew