berko
berko

Reputation: 2975

Assemble site generation from a single json data source

I am struggling to bend Assemble to my needs, and I happily acknowledge that it may not be the right tool for the job.

I would like to have a single json datasource. say:

{
  blogindex: {
    blogs: [
      {
        name: "Blog1",
        posts: ["Post1","Post2]
      },
      {
        name: "Blog2",
        posts: ["Post3","Post4]
      }
    ]
  }
}

And have it generate a site with a similar folder structure to:

blogindex/
  index.html
  blog1/
    index.html
      posts/
        post1.html
        post2.html
    blog2/
    index.html
      posts/
        post3.html
        post4.html

The exact structure is not that important but I am running into dead-ends trying to use a single datasource to generate any hierarchical structure.

I have tried each blog having its own 'blog-1.json' with no success, either.

Upvotes: 2

Views: 119

Answers (1)

doowb
doowb

Reputation: 3372

@berko we do have a pages collection that can be added to the assemble options, so you could dynamically generate the needed tasks for each blog.

From what you posted, I'm assuming that each blog would be independent of each other (except for the blogindex/index.html page so you could generate the targets...

https://gist.github.com/doowb/8467651

This isn't tested, but I think it might work using the pages option and building it dynamically.

FWIW, we're refactoring assemble and hopefully things like this will be a lot easier to do with plugins.

Upvotes: 1

Related Questions