blakeembrey / metalsmith-pagination

A Metalsmith plugin for paginating arrays and collections
MIT License
34 stars 10 forks source link

How can this plugin be used by other metalsmith plugins? #1

Closed hswolff closed 9 years ago

hswolff commented 9 years ago

Hello! I'm currently working on adding pagination to the metalsmith-tags plugin. I'd love to use this plugin alongside my modifications in the tags plugin however I'm a little stuck as to how I can go about doing so.

Currently this plugin requires fixed knowledge of all collections and arrays so that it can create the pagination files.

However with the tags plugin I don't know what tags are going to exist until runtime. At the point when I know what tags I want to paginate I can no longer modify the pagination options object.

So this is more of a question and brainstorm of how I could use this plugin alongside the tags plugin. Can I do so as this plugin currently exists, or as I suspect, some modifications are required for this plugin.

blakeembrey commented 9 years ago

@hswolff I don't know much about the tags plugin, but you should be able to use it if the tags is an array. For example, just call paginate({ 'tags.x': { perPage: 5, ... } })(files, metalsmith, done) within the tags plugin. If that comment doesn't help, I can help contribute to your PR and see if we can refactor it a little. I see there's tests :smile:

hswolff commented 9 years ago

Ooooh clever solution. Gonna try that for sure :D.

I was thinking of abstracting out the pagination function into something else, but I honestly can't think of anything more easy to use than the example you just laid out.

I likey!

hswolff commented 9 years ago

So at this point metalsmith-pagination can't be directly used by metalsmith-tags without modifications to metalsmith-pagination.

Going to close this issue for now and if/when I truly tackle this I'll submit a PR with the changes necessary to make it work with metalsmith-tags.