Skip to content

Commit e519d85

Browse files
committed
improve(integrations): handle case where social cards cache dir is not relative to build folder
1 parent 24b915f commit e519d85

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

mkdocs_rss_plugin/integrations/theme_material_social_plugin.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,26 @@ def get_social_cards_cache_dir(self, mkdocs_config: MkDocsConfig) -> Path:
250250
Path: The cache dir if the theme material and the plugin social cards is enabled.
251251
"""
252252
social_plugin_cfg = mkdocs_config.plugins.get("material/social")
253-
self.social_cards_cache_dir = Path(social_plugin_cfg.config.cache_dir).resolve()
253+
254+
if (
255+
Path(social_plugin_cfg.config.cache_dir)
256+
.resolve()
257+
.is_relative_to(Path(mkdocs_config.config_file_path).parent.resolve())
258+
):
259+
self.social_cards_cache_dir = Path(
260+
social_plugin_cfg.config.cache_dir
261+
).resolve()
262+
else:
263+
self.social_cards_cache_dir = (
264+
Path(mkdocs_config.config_file_path)
265+
.parent.resolve()
266+
.joinpath(social_plugin_cfg.config.cache_dir)
267+
)
254268

255269
logger.debug(
256-
"Material Social cards cache folder: " f"{self.social_cards_cache_dir}."
270+
"Material Social cards cache folder: "
271+
f"{self.social_cards_cache_dir}. "
272+
f"Already exists: {self.social_cards_cache_dir.is_dir()}"
257273
)
258274

259275
return self.social_cards_cache_dir

0 commit comments

Comments
 (0)