permalinks
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'
I think this is good alternative to setting "permalink: false" in the front matter for people who want to rely more on metalsmith-collections.
+1, should be merged, very useful (if multiple invocations are supported, which PR #26 seem to confirm).
:+1: wanted this kind of functionality for a while :wink: #17
@ianstormtaylor any chance of this getting merged in?
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 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.
The array is basically what #26 accomplishes though. That one's working like a treat for me.
Thanks for the PR.
Could you resolve the conflicts or create a new PR based off master?