Fix table of contents issues with nested items

The table of contents was correctly displaying subitems as a list within the chapter list, but it was also incorrectly displaying the subitems as top-level items after the chapter item. This seems to be because the `getTOC` method iterates over all of the `navPoint` items and is used recursively without distinguishing between top-level items and subitems.

I added a ternary operator to account for this when setting the `nodes` variable and it seems to handle the table of contents more predictably (i.e. the subitems aren't displayed as top-level items anymore). There might be a better way to handle this in the future but this works for now.

Fixes #122 and fixes #129.