-
Notifications
You must be signed in to change notification settings - Fork 32
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
Hide toc or navigation seems not work #39
Comments
After I modified the following code at page = dict(
title=page_title,
is_homepage=(pagename == context["master_doc"]),
toc=local_toc,
meta={"hide": meta.get("hide", []), "revision_date": context.get("last_updated")},
content=context.get("body"),
) |
No. This is not mkdocs. This theme is for sphinx which generally uses rst (restructuredText) files. If you're using md files then you're likely using a sphinx extension to do so. In which case the meta data that can be used in mkdocs-material is not always supported in sphinx-immaterial. On that note, all the markdown extensions used by mkdocs-material are not used by sphinx-immaterial. You can have a look at this theme's docs to see how to customize it. I don't think that hiding the sidebars are a supported feature in this theme. |
In rst files, adding meta data would be done at the top of the file like so: :hide: toc, navigation
.. or
:hide: toc
:hide: navigation I have not tested this. What sphinx extension are you using to use md files? |
I misread this comment. You're welcome to submit a PR with your changes, but I'd ask that there be some addition to this theme's docs on how to use the metadata (in RST files). |
Thanks for your answering. Great help.
I double checked the docs, there is no guidance to hide toc or navigation. I think I use the theme incorrectly, I did not notice the meta data that can be used in mkdocs-material is not always supported in sphinx-immaterial.
I have tested it, seems not work. I think the code I am not familiar with Sphinx, I am not sure if this is the reason.
I am using myst_parser extension which allows to write MyST Markdown in Sphinx. |
From looking at the nav_adapt.py, I see that you can hide the toc by using :tocdepth: 0
..
I'm not sure what this would look like in MD. but I don't see support for hiding the navigation. |
I was able to add support for hiding navigation by changing sphinx-immaterial/sphinx_immaterial/nav_adapt.py Lines 457 to 458 in 6ceccff
to if meta:
if meta.get("tocdepth") == 0:
page["meta"]["hide"].append("toc")
if meta.get("hide") == "navigation":
page["meta"]["hide"].append("navigation") This means the following metadata would need to be used to hide the toc and the navigation: :tocdepth: 0
:hide: navigation This is a worthy contribution opportunity. Remember, the docs would need to be updated as well (preferrably after the |
@zclab Please update your install of sphinx-immaterial in a few hours. v0.4 has added support for this issue. Thank you for bringing this to our attention. After more discussion (in #40) about how to implement this, we've settled on :hide-navigation:
:hide-toc: Additionally, the following will still work to hide the toc :tocdepth: 0 I had a look at the MyST parser extension, and I didn't see any explicit mention of supporting metadata. However, given the discussion in executablebooks/MyST-Parser#286 , you could try using ---
hide-navigation: true
hide-toc: true
--- or optionally (to just hide the toc) ---
tocdepth: 0
--- |
Cool 👍, thanks ! |
Is that confirming that it works with MyRST parser? |
Yes, it works very well. |
When I try to hide table of contents sidebars or navigation, it did not work. I add the following line in markdown files
Is this the right method to hide table of contents sidebars or navigation? Thanks.
The text was updated successfully, but these errors were encountered: