magicbookproject / magicbook

The magic book project returns!
MIT License
1.07k stars 59 forks source link

Table of Contents Questions #6

Closed shiffman closed 8 years ago

shiffman commented 8 years ago

I've read the TOC section in the README and have some questions / clarification.

This is what I have:

includes/toc.html:

<nav data-type='toc'>
  <h1>Table of Contents</h1>
  <ol>
    {% include toc_item.html children=toc.children %}
  </ol>
</nav>

toc.html:

<section data-type="toc" id="_toc">
{{TOC}}
</section>

chapter1.html:

<section data-type="chapter">
content
</section>

The README makes reference to:

{
  id: "#id-of-the-section",
  type: "Type of HTMLBook section",
  label: "Title for section",
  children: [] // array of child sections
}

But I'm not exactly sure where the above should go and how it should be formed / related to data-type="chapter">.

Does my question make sense?

runemadsen commented 8 years ago

Yes, that totally makes sense. I know that reference in the README is a bit confusing, and you should feel free to rewrite whatever doesn't make sense.

That object is basically what gets passed to the toc.html liquid include, and this happens automatically. So you should be able to add the {{ toc }} tag, add the toc.html include, and add the toc_item.html include and it just just work. You can take a look in the example folder on the magicbook github to see a working project.

Also, you should update to version 0.1.5 of magicbook. There's a ton of changes!