Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance for MkDocs 1.5.0 #31

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions mkdocs_minify_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,21 @@ def _minify_extra_config(self, file_type: str, config: MkDocsConfig) -> None:
# A valid path in a custom_dir takes priority.
if self.config["cache_safe"]:
docs_file_path: str = f"{config['docs_dir']}/{file_path}".replace("\\", "/")

for user_config in config.user_configs:
user_config: Dict
custom_dir: str = user_config.get("theme", {}).get("custom_dir", "")
temp_path: str = f"{custom_dir}/{file_path}".replace("\\", "/")
if custom_dir and os.path.exists(temp_path):
theme = config.theme

# Since MkDocs 1.5.0, theme.custom_dir is available for direct access
if not hasattr(theme, "custom_dir"):
for user_config in config.user_configs:
user_config: Dict
custom_dir: str = user_config.get("theme", {}).get("custom_dir", "")
temp_path: str = f"{custom_dir}/{file_path}".replace("\\", "/")
if custom_dir and os.path.exists(temp_path):
docs_file_path = temp_path
break
elif theme.custom_dir:
temp_path: str = f"{theme.custom_dir}/{file_path}".replace("\\", "/")
if os.path.exists(temp_path):
docs_file_path = temp_path
break

with open(docs_file_path, encoding="utf8") as file:
file_data: str = file.read()
Expand Down