Skip to content

Commit 377ed83

Browse files
committed
feature(social_cards): add a method to determine if the material theme is in Insiders or Community edition
1 parent a51c596 commit 377ed83

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

mkdocs_rss_plugin/integrations/theme_material_social_plugin.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
# package
1616
from mkdocs_rss_plugin.constants import MKDOCS_LOGGER_NAME
1717

18+
# conditional
19+
try:
20+
from material import __version__ as material_version
21+
except ImportError:
22+
material_version = None
23+
1824
# ############################################################################
1925
# ########## Globals #############
2026
# ################################
@@ -32,6 +38,7 @@ class IntegrationMaterialSocialCards:
3238
IS_SOCIAL_PLUGIN_ENABLED: bool = True
3339
IS_SOCIAL_PLUGIN_CARDS_ENABLED: bool = True
3440
IS_THEME_MATERIAL: bool = False
41+
IS_INSIDERS: bool = False
3542

3643
def __init__(self, mkdocs_config: Config, switch_force: bool = True) -> None:
3744
"""Integration instanciation.
@@ -84,6 +91,23 @@ def is_theme_material(self, mkdocs_config: Config) -> bool:
8491
self.IS_THEME_MATERIAL = mkdocs_config.theme.name == "material"
8592
return self.IS_THEME_MATERIAL
8693

94+
def is_theme_material_insiders(self) -> bool | None:
95+
"""Check if the material theme is community or insiders edition.
96+
97+
Returns:
98+
bool: True if the theme is Insiders edition. False if community. None if
99+
the Material theme is not installed.
100+
"""
101+
if not self.IS_THEME_MATERIAL:
102+
return None
103+
104+
if material_version is not None and "insiders" in material_version:
105+
logger.debug("Material theme edition INSIDERS")
106+
return True
107+
else:
108+
logger.debug("Material theme edition COMMUNITY")
109+
return False
110+
87111
def is_social_plugin_enabled_mkdocs(self, mkdocs_config: Config) -> bool:
88112
"""Check if social plugin is installed and enabled.
89113

0 commit comments

Comments
 (0)