I am looking for some advice on how to display material in a hierarchical table of contents. I have been charged with making the entire contents of a short book available via Bixby. This raises a lot of interesting issues about how to create conversations around the content, when less is more, etc., but the v0 requirement is just to get it all accessible. The content is more or less organized like this:
Part One
Chapter One
Section 1.1
Section 1.2
Image 1.1
Chapter Two
Chapter Three
Section 3.1
Section 3.1.1
I say more or less because there are annoying logical variations like section headings without content or sections that have multiple headlines. The Sections are generally short enough to be good Bixby pages.
The content resides in a restdb with each section of text in its own row. The concept that contains the content is called, unsurprisingly, Content, and it has a contenttype property that can be news, facts, quiz, etc.
My first and basic question is how to create a Table of Contents that correctly displays all these Content objects in the right sequence and a readable format. In other words, the layout will probably be a little more complex than the standard Bixby list view and I will need some mechanism for sorting the returned objects into the right slots.
Ideally, you would do all the parsing of the content in your Javascript and pass a Structure
containing all the nested sub-headings as nested Structures.
For example, there would be the main structure TableOfContents
with a Chapter
structure as its property (min Optional, max Many). Each Chapter
structure would have Section
and Image
properties (min Optional, max Many).
If Section
and Image
are the deepest your nesting will go, these can be Name
and Text
primitives. However, if your Image
requires multiple parts such as a url, description, etc., you would continue the same way as before.
Once you've defined the contents, you would use conditionals in your View to render the ToC for all the content headings that are available in an appropriate manner.