The markup for the anchors of the table of contents requires the ID of an HTML element plus a label. This data lends itself to a block mapping in YAML Front Matter, which is a collection of key: value
pairs. After a quick Google search, I found out how to achieve this in Jekyll on Stack Overflow (as is so often the case).
Below is a sample of the YAML Front Matter in one of the handbooks:
And the code to generate the table of contents in the layout:
In the code sample above chapter[0]
gets the key and chapter[1]
the value of the pair, i.e. #welcome
and Welcome
.
An example of the generated HTML is as follows:
Block mapping will allow me to create more complex layouts in Jekyll using YAML Front Matter.
The idea behind the Next handbooks is to document our culture, processes and tools. Anyone at Next can contribute to the them and those outside get an insight in to who we are and how we work.