Skip to content

Commit

Permalink
Merge pull request #30 from oprypin/extr
Browse files Browse the repository at this point in the history
Compatibility with MkDocs 1.5 change to `extra_javascript`
  • Loading branch information
wilhelmer committed Jul 25, 2023
2 parents 841f17b + 5168b6c commit af51df2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mkdocs_minify_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def _minify_extra_config(self, file_type: str, config: MkDocsConfig) -> None:
if not isinstance(files_to_minify, list):
files_to_minify = [files_to_minify]

for i, file_path in enumerate(config[extra]):
for i, extra_item in enumerate(config[extra]):
file_path = str(extra_item)

if file_path not in files_to_minify:
continue

Expand Down Expand Up @@ -178,7 +180,11 @@ def _minify_extra_config(self, file_type: str, config: MkDocsConfig) -> None:
# store hash for use in `on_post_build`
self.path_to_hash[file_path] = file_hash

config[extra][i] = self._minified_asset(file_path, file_type, file_hash)
new_file_path = self._minified_asset(file_path, file_type, file_hash)
if isinstance(extra_item, str):
config[extra][i] = new_file_path
else: # MkDocs 1.5: ExtraScriptValue.path
extra_item.path = new_file_path

def on_post_page(self, output: str, *, page: Page, config: MkDocsConfig) -> Optional[str]:
"""Minify HTML page before saving to disk."""
Expand Down

0 comments on commit af51df2

Please sign in to comment.