user3151245
user3151245

Reputation: 1

URL structure and JSON on assemble.io with multiple index.html files?

I cant get Assemble to get correct index.json to correct index.hbs file. With this setup it takes only the last index.json file to populate both my index.hbs files.

Is this url structure possible with Grunt and Assemble?

I have a folder structure like this:

/src/pages/index.hbs
/src/pages/subfolder/index.hbs

and json data structure like

/src/data/index.json
/src/data/subfolder/index.json

and Gruntfile.js (assemble part) like this:

assemble: {
options: {
production: false,
        expand: true,
        site: '<%= pkg %>',
        assets: 'dist/assets',
        partials: ['src/includes/\*.hbs'],
        helpers: ['src/helpers/helper-\*.js'],
        layout: 'src/layouts/default.hbs',
        data: ['src/data/\*\*/\*.json']
    },
    pages: {
        expand: true,
        cwd: 'src/pages',
        src: ['\*\*/\*.hbs'],
        dest: 'dist/'
    }<br/>
}

Upvotes: 0

Views: 260

Answers (1)

Kelly J Andrews
Kelly J Andrews

Reputation: 5111

The data in Assemble will merge together and be available at the top level.

Two options that I know of -

  1. Rename the json files and call that within the index page you need.
  2. Move each section into it's own assemble target and pass the data in that target's options object.

Let me know if that helps.

Upvotes: 1

Related Questions