Skip to content

Commit 9a628e1

Browse files
authored
feat: Add toc.json transform logics using toc.extension.js (#9953)
feat: Add toc.json transform logics
1 parent 42a328f commit 9a628e1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

templates/default/toc.extension.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
/**
5-
* This method will be called at the start of exports.transform in toc.html.js
5+
* This method will be called at the start of exports.transform in toc.html.js and toc.json.js
66
*/
77
exports.preTransform = function (model) {
88
return model;
99
}
1010

1111
/**
12-
* This method will be called at the end of exports.transform in toc.html.js
12+
* This method will be called at the end of exports.transform in toc.html.js and toc.json.js
1313
*/
1414
exports.postTransform = function (model) {
1515
return model;

templates/default/toc.json.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
3+
var extension = require('./toc.extension.js')
34

45
exports.transform = function (model) {
56

7+
if (extension && extension.preTransform) {
8+
model = extension.preTransform(model);
9+
}
10+
611
if (model.memberLayout === 'SeparatePages') {
712
model = transformMemberPage(model);
813
}
14+
15+
if (extension && extension.postTransform) {
16+
model = extension.postTransform(model);
17+
}
918

1019
for (var key in model) {
1120
if (key[0] === '_') {

0 commit comments

Comments
 (0)