Skip to content

Commit 772421d

Browse files
authored
Merge pull request #5759 from kamilkrzyskow/social-patch2
Social plugin maintenance for MkDocs 1.5.0
2 parents 3e8faa0 + f548d79 commit 772421d

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

material/plugins/social/plugin.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]):
7878

7979
def __init__(self):
8080
self._executor = concurrent.futures.ThreadPoolExecutor(4)
81-
self.custom_dir = None
8281

8382
# Retrieve configuration
8483
def on_config(self, config):
@@ -145,13 +144,6 @@ def on_config(self, config):
145144
"text": options.get("color", self.color["text"])
146145
}
147146

148-
# Retrieve custom_dir path
149-
for user_config in config.user_configs:
150-
custom_dir = user_config.get("theme", {}).get("custom_dir")
151-
if custom_dir:
152-
self.custom_dir = custom_dir
153-
break
154-
155147
# Retrieve logo and font
156148
self._resized_logo_promise = self._executor.submit(self._load_resized_logo, config)
157149
self.font = self._load_font(config)
@@ -403,8 +395,8 @@ def _load_logo(self, config):
403395
path = os.path.join(config.docs_dir, theme["logo"])
404396

405397
# Allow users to put the logo inside their custom_dir (theme["logo"] case)
406-
if self.custom_dir:
407-
custom_dir_logo = os.path.join(self.custom_dir, theme["logo"])
398+
if theme.custom_dir:
399+
custom_dir_logo = os.path.join(theme.custom_dir, theme["logo"])
408400
if os.path.exists(custom_dir_logo):
409401
path = custom_dir_logo
410402

@@ -431,8 +423,8 @@ def _load_logo(self, config):
431423
path = f"{base}/.icons/{logo}.svg"
432424

433425
# Allow users to put the logo inside their custom_dir (theme["icon"]["logo"] case)
434-
if self.custom_dir:
435-
custom_dir_logo = os.path.join(self.custom_dir, ".icons", f"{logo}.svg")
426+
if theme.custom_dir:
427+
custom_dir_logo = os.path.join(theme.custom_dir, ".icons", f"{logo}.svg")
436428
if os.path.exists(custom_dir_logo):
437429
path = custom_dir_logo
438430

src/plugins/social/plugin.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]):
7878

7979
def __init__(self):
8080
self._executor = concurrent.futures.ThreadPoolExecutor(4)
81-
self.custom_dir = None
8281

8382
# Retrieve configuration
8483
def on_config(self, config):
@@ -145,13 +144,6 @@ def on_config(self, config):
145144
"text": options.get("color", self.color["text"])
146145
}
147146

148-
# Retrieve custom_dir path
149-
for user_config in config.user_configs:
150-
custom_dir = user_config.get("theme", {}).get("custom_dir")
151-
if custom_dir:
152-
self.custom_dir = custom_dir
153-
break
154-
155147
# Retrieve logo and font
156148
self._resized_logo_promise = self._executor.submit(self._load_resized_logo, config)
157149
self.font = self._load_font(config)
@@ -403,8 +395,8 @@ def _load_logo(self, config):
403395
path = os.path.join(config.docs_dir, theme["logo"])
404396

405397
# Allow users to put the logo inside their custom_dir (theme["logo"] case)
406-
if self.custom_dir:
407-
custom_dir_logo = os.path.join(self.custom_dir, theme["logo"])
398+
if theme.custom_dir:
399+
custom_dir_logo = os.path.join(theme.custom_dir, theme["logo"])
408400
if os.path.exists(custom_dir_logo):
409401
path = custom_dir_logo
410402

@@ -431,8 +423,8 @@ def _load_logo(self, config):
431423
path = f"{base}/.icons/{logo}.svg"
432424

433425
# Allow users to put the logo inside their custom_dir (theme["icon"]["logo"] case)
434-
if self.custom_dir:
435-
custom_dir_logo = os.path.join(self.custom_dir, ".icons", f"{logo}.svg")
426+
if theme.custom_dir:
427+
custom_dir_logo = os.path.join(theme.custom_dir, ".icons", f"{logo}.svg")
436428
if os.path.exists(custom_dir_logo):
437429
path = custom_dir_logo
438430

0 commit comments

Comments
 (0)