blakeembrey / metalsmith-pagination

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

Switching to metalsmith-layouts #17

Closed patdavid closed 8 years ago

patdavid commented 8 years ago

I recently upgraded a bunch of outdated packages on my site, and have run into a bit of a problem.

I was previously using metalsmith-templates, but with it being deprecated figured it was about time to upgrade. Everything else is working fine for me at the moment switching to metalsmith-layouts with the sole exception of metalsmith-pagination... :(

The relevant sections of my index.js show what everything mostly looked like when it was working fine with metalsmith-templates:

...
paginate    = require('metalsmith-pagination'),
...

.use(paginate({
        'collections.blogposts':{
            perPage: 10,
            //template: 'test.hbt'
            //template: 'blog-list-pages.hbt',
            layout: 'blog-list-pages.hbt',
            first: '/blog/index.html',
            path: '/blog/page-:num.html',
            pageMetadata: {
                title: 'Blog'
            }
        }
    }))

The only difference between it previously working and now is the change from metalsmith-templates to metalsmith-layouts, and the requisite change of the template: key to layouts: - which seemed to be straightforward. The problem is that I am not getting any of my generated output as expected previously. Any ideas on moving forward to troubleshoot?

patdavid commented 8 years ago

After playing a bit with things, my problems were with the paths for first and path. Changing them to:

.use(paginate({
        'collections.blogposts':{
            perPage: 10,
            //template: 'test.hbt'
            //template: 'blog-list-pages.hbt',
            layout: 'blog-list-pages.hbt',
            first: 'blog/index.html',
            path: 'blog/page-:num.html'
            //noPageOne: true
            //pageMetadata: {
            //    title: 'Blog'
            //}
        }
    }))

Solved my problem! Thank you! :D