Created on 04 Sep 2014 ;    Modified on 23 Aug 2016 ;    Translationitalian

TiddlyWiki5: how to add a table of contents in sidebar

In the past I have written a few notes about TiddlyWiki (classic).

Now there is a new version, TiddlyWiki 5, not fully compatible with the previus (classic) version 2.x.y.

It is an extended code rewriting with a new layout and a rationalization of the code.

According to the developers, there is a substantial increase of flexibility. That, and this is just my observation, is accompanied by a considerable increase in the amount of code (over 1 MByte; the previous v.2.8.1 stopped at 392 KByte).

Among the many new faetures, there is a macro to create table of contents.

The logic is simple.

The tiddlers to be the main entries in the index, must be tagged with a conventional value decided by us. For example, let's say we want to use the tag Main. And let's say we create two main chapters: Introduction and FirstPhase, which we assign the tag Main.

The tiddlers that represent chapters of the second level should be tagged with the title of the chapter of the first level to which they belong. In our example, if we have two chapters in Introduction (let's say BookGoal and UsedConventions) both tagged with Introduction. While we are going to tag the subentries of FirstPhase (eg RequirementsDefinition and FunctionaAnalisys) with FirstPhase.

At this point we create a tiddler Contents in which we put this code:

 <div class = 'tc-table-of-contents'>
 << toc-selective-expandable 'Main' >>
 </ div>

and we set its tag as $:/tags/SideBar.

Done. In the right sidebar will appear the label Contents and by selecting it we'll find our collapsed index.

In TiddlyWiki site you can see an example of use from which extrapolate more information. For example, you have understood that the format of the index can be of different types (extended, collapsible, ...). It's also possible to order the items.