From 9a628e1c1a19d2dd05beea171ed1c665f376f278 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 27 May 2024 11:56:23 +0900 Subject: [PATCH] feat: Add `toc.json` transform logics using `toc.extension.js` (#9953) feat: Add toc.json transform logics --- templates/default/toc.extension.js | 4 ++-- templates/default/toc.json.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/templates/default/toc.extension.js b/templates/default/toc.extension.js index 672dd793522..0a85459080a 100644 --- a/templates/default/toc.extension.js +++ b/templates/default/toc.extension.js @@ -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; diff --git a/templates/default/toc.json.js b/templates/default/toc.json.js index a59b350eed9..8c57d0016d2 100644 --- a/templates/default/toc.json.js +++ b/templates/default/toc.json.js @@ -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] === '_') {