1 // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
2 var extension = require('./toc.extension.js')
4 exports.transform = function (model) {
6 if (extension && extension.preTransform) {
7 model = extension.preTransform(model);
10 transformItem(model, 1);
11 if (model.items && model.items.length > 0) model.leaf = false;
12 model.title = "Table of Content";
13 model._disableToc = true;
15 if (extension && extension.postTransform) {
16 model = extension.postTransform(model);
21 function transformItem(item, level) {
22 // set to null incase mustache looks up
23 item.topicHref = item.topicHref || null;
24 item.tocHref = item.tocHref || null;
25 item.name = item.name || null;
28 if (item.items && item.items.length > 0) {
29 var length = item.items.length;
30 for (var i = 0; i < length; i++) {
31 transformItem(item.items[i], level + 1);