Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Build-time TOC customization with toc.extension.js is not works when using modern template #9944

Closed
filzrev opened this issue May 22, 2024 · 1 comment · Fixed by #9953
Labels
bug A bug to fix

Comments

@filzrev
Copy link
Contributor

filzrev commented May 22, 2024

Describe the bug

docfx support build-time TOC customization by using toc.extension.js file.
But it's applied to generated html files only. Original toc.json file is not modified.

When using modern template. Generated toc.html is not used.
And toc.json file is used instead.
So build-time TOC customization is not works when using modern template.

To Reproduce

Steps to reproduce the behavior:

  1. Create custom template and place custom toc.extension.js file.
  2. Run docfx build command
  3. Confirm generated toc.html and toc.json content.

Expected behavior

TOC customization with toc.extension.js works same as default template when using modern template.

Context (please complete the following information):

  • OS: Windows
  • Docfx version: [e.g. 2.76.0]
@filzrev filzrev added the bug A bug to fix label May 22, 2024
@filzrev
Copy link
Contributor Author

filzrev commented May 26, 2024

It can apply toc.extension.js to generated toc.json file by adding following logics to toc.json.js that similar to toc.html.primary.js.

var extension = require('./toc.extension.js')

exports.transform = function (model) {

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

  // Run existing `toc.json.js` logics here
  
  if (extension && extension.postTransform) {
    model = extension.postTransform(model);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant