Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining permalinks with a data collection - how? #58

Open
tomsoderlund opened this issue Jan 20, 2015 · 4 comments
Open

Combining permalinks with a data collection - how? #58

tomsoderlund opened this issue Jan 20, 2015 · 4 comments

Comments

@tomsoderlund
Copy link

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?

@tomsoderlund tomsoderlund changed the title Combining permalinks with a data collection Combining permalinks with a data collection - how? Jan 20, 2015
@designorant
Copy link

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
Copy link
Author

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
Copy link
Member

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
Copy link
Member

and thank you @designorant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants