assemble / grunt-assemble-permalinks

Permalinks middleware for Assemble, the static site generator for Grunt.js and Yeoman. This plugin enables powerful and configurable URI replacement patterns, presets, uses Moment.js for parsing dates, and much more.
MIT License
43 stars 11 forks source link

Combining permalinks with a data collection - how? #58

Open tomsoderlund opened 9 years ago

tomsoderlund commented 9 years ago

I have a JSON file landingpages.json that currently spits out HTML files in the format dist/[pageName].html and now I'm trying to use this middleware to produce dist/[pageName]/index.html, but can't get it to work:

landingpages: {
    options: {
        flatten: true,
        assets: '<%= config.dist %>',
        engine: 'handlebars',
        layoutdir: '<%= config.src %>/templates/layouts',
        layout: 'landingpage.hbs',
        partials: '<%= config.src %>/templates/partials/*.hbs',
        helpers: ['<%= config.src %>/helpers/*.js'],
        data: '<%= config.src %>/data/*.{json,yml}',
        pages: grunt.file.readJSON('src/data/landingpages.json'),
        permalinks: {
            structure: ':basename/:index.html'
        }
    },
    files: { '<%= config.dist %>/': ['<%= config.src %>/templates/pages/index.hbs'] }
},

Any suggestions?

designorant commented 9 years ago

Looks like it's a formatting issue rather than anything to do with your data files.

You've got an extra colon in there. Try:

permalinks: {
    structure: ':basename/index.html'
}
tomsoderlund commented 9 years ago

Thanks for spotting, but yields same results (= pages are created in dist/[pageName].html format). I think there's perhaps something with my files: setting?

files: { '<%= config.dist %>/': ['<%= config.src %>/templates/pages/index.hbs'] }
jonschlinkert commented 9 years ago

hmm, it's possible that the pages generated via the pages property are causing issues. Have you tried with and without pages to see if permalinks works without it?

jonschlinkert commented 9 years ago

and thank you @designorant!