-
I would like to set an icon in the section titles in the navigation, just as icons set in pages via
I have looked at the code, but it seems it's only supported in pages. mkdocs-material/material/templates/partials/nav-item.html Lines 14 to 16 in 8df393d I could try to override that macro to include icons in sections, but my question is: Which would be the best way to specify the icon in a section? I have thought of different options:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hello @joapuiib, Sections don't have any metadata by default, and the main issue is how to store and link the icon to a specific section, I believe there is only the If the side effect of duplicate Section titles doesn't concern you, my suggestion would be to make use of either the
IIRC you're making your own theme, extending the Material theme, so you could go the route of modifying the MkDocs
This would be the less hacky approach, as you would work on the parsed and validated Navigation object in the event loop and would simply add the data from the
I don't think this approach is needed, as the
|
Beta Was this translation helpful? Give feedback.
-
Great discussion and insights. Another way to achieve this is through awesome-pages plugin, and using Unicode emojis in the alternate title, which are now largely supported by systems (client side). On Windows, you get them with the windows key + ";". The challenge is that they are not coming from the material icon library. Example of a nav:
- "🏠 DOFLinx": README.md
- "🚀 Getting Started": getting-started
- "⚙️ Parameters": parameters
- "🕹️ Systems": systems
- "🌟 Misc": Misc
- "🆘 Help": 07_Help.md
- ... |
Beta Was this translation helpful? Give feedback.
Thanks for your detailed answer! It is really inspiring!
I've managed to do it with
awesome-pages-plugin
and thefilter
idea.extract_icon
andremove_icon
: