Skip to content

Commit

Permalink
feat: show default icon for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Nov 17, 2024
1 parent d0cb088 commit ca370d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mkdocs_nype/plugins/nype_tweaks/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
tweak doesn't make things easier. Global placeholder loading was moved to the
post-card.html template.
7. Enable default tag icon tweak:
The Material tags plugin allows to set icons for each tag, however there is
also the default icon, which isn't turned on without setting other icon mappings.
The tweak sets the required settings to show the default icon on tags.
https://github.com/squidfunk/mkdocs-material/issues/7688
MIT License 2024 Kamil Krzyśków (HRY) for Nype (npe.cm)
"""

Expand Down Expand Up @@ -95,6 +101,16 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
if not ServeMode.run_once:
macros_module.FileSystemLoader = utils.get_file_system_loader

# Enable default tag icon tweak
if not config.theme.get("icon"):
config.theme["icon"] = {}
if not config.theme["icon"].get("tag"):
config.theme["icon"]["tag"] = {}
if not config.theme["icon"]["tag"].get("default"):
config.theme["icon"]["tag"]["default"] = "material/tag"
if not config.extra.get("tags"):
config.extra["tags"] = {"_": "_"}

LOG.info("Tweaks initialized")

def on_env(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "hatchling.build"

[project]
name = "mkdocs-nype"
version = "0.22.1"
version = "0.22.2"
description = "MkDocs theme for Nype MkDocs projects, extends the Material for MkDocs theme"
authors = [
{ name = "Kamil Krzyśków", email = "[email protected]" }
Expand Down

0 comments on commit ca370d2

Please sign in to comment.