Skip to content

Is it possible to access the toc of a different page than the current page? #7900

Answered by kamilkrzyskow
divSelector asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @divSelector,
accessing different TOCs should be straightforward, there is the global context with:

  • nav, which contains pages, a flat list of Page objects
    • so you access the page and toc with a loop for page in nav.pages and then page.toc
  • pages, a flat list of File objects
    • so you access the page and toc with a loop for file in pages and then file.page.toc

As for the application, I'm unsure whether it would work like you envision it 🤔, as the toc likely doesn't contain actual links including the file path, but instead they probably just contain the #href_id nothing more, so you'd have to tinker with it to get the result you want. So perhaps a custom toc.html is also required t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@divSelector
Comment options

Answer selected by divSelector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants