Skip to content

Commit

Permalink
feat: Add toc.json transform logics using toc.extension.js (#9953)
Browse files Browse the repository at this point in the history
feat: Add toc.json transform logics
  • Loading branch information
filzrev authored May 27, 2024
1 parent 42a328f commit 9a628e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions templates/default/toc.extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.

/**
* This method will be called at the start of exports.transform in toc.html.js
* This method will be called at the start of exports.transform in toc.html.js and toc.json.js
*/
exports.preTransform = function (model) {
return model;
}

/**
* This method will be called at the end of exports.transform in toc.html.js
* This method will be called at the end of exports.transform in toc.html.js and toc.json.js
*/
exports.postTransform = function (model) {
return model;
Expand Down
9 changes: 9 additions & 0 deletions templates/default/toc.json.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
var extension = require('./toc.extension.js')

exports.transform = function (model) {

if (extension && extension.preTransform) {
model = extension.preTransform(model);
}

if (model.memberLayout === 'SeparatePages') {
model = transformMemberPage(model);
}

if (extension && extension.postTransform) {
model = extension.postTransform(model);
}

for (var key in model) {
if (key[0] === '_') {
Expand Down

0 comments on commit 9a628e1

Please sign in to comment.