简体   繁体   English

从单个json数据源组装网站生成

[英]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. 我正在努力使Assembly满足我的需求,并且我很高兴地承认这可能不是适合该工作的工具。

I would like to have a single json datasource. 我想拥有一个json数据源。 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. 我已经尝试过每个博客都有自己的'blog-1.json',但也没有成功。

@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. @berko我们确实有一个页面集合,可以将其添加到汇编选项中,因此您可以为每个博客动态生成所需的任务。

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... 根据您发布的内容,我假设每个博客都是彼此独立的(blogindex / index.html页面除外,因此您可以生成目标...

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

This isn't tested, but I think it might work using the pages option and building it dynamically. 尚未对此进行测试,但我认为可以使用pages选项并动态构建它。

FWIW, we're refactoring assemble and hopefully things like this will be a lot easier to do with plugins. FWIW,我们正在重构汇编,希望使用插件可以很容易地完成类似的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM