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

Table of Contents (TOC) #220

Open
loganthomas opened this issue Sep 13, 2024 · 2 comments
Open

Table of Contents (TOC) #220

loganthomas opened this issue Sep 13, 2024 · 2 comments

Comments

@loganthomas
Copy link

In markdown files, the navigation and/or table of contents sidebars can be hidden for a document with the front matter hide property xref

---
hide:
  - toc
---

Is there a way to do this in a notebook using mkdocs-jupyter?

@patnr
Copy link

patnr commented Nov 4, 2024

Maybe try this #99 (comment)

@loganthomas
Copy link
Author

Thank you!!

This worked for me:

// See https://github.com/danielfrg/mkdocs-jupyter/issues/99#issuecomment-2455307893
// See https://github.com/danielfrg/mkdocs-jupyter/issues/220
// Using the document$ observable from mkdocs-material to get notified of page "reload" also if using `navigation.instant` (SSA)
document$.subscribe(function() {
  // First check if the page contains a notebook-related class
  if (document.querySelector('.jp-Notebook')) {
    // "div.md-sidebar.md-sidebar--primary" is the navigation
    // "div.md-sidebar.md-sidebar--secondary is the table of contents
    //document.querySelector("div.md-sidebar.md-sidebar--primary").remove();
    document.querySelector("div.md-sidebar.md-sidebar--secondary").remove();
  }
});

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

No branches or pull requests

2 participants