Skip to content

Commit

Permalink
Merge pull request #120 from BartvanWoesik/master
Browse files Browse the repository at this point in the history
Fix for invalid warning when using hooks in mkdocs
  • Loading branch information
timvink authored Sep 12, 2024
2 parents 7e218f2 + 4df248b commit cabda6f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mkdocs_print_site_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ def on_config(self, config, **kwargs):
# it is important 'print-site' is defined last in the 'plugins'
plugins = config.get("plugins")
print_site_position = [*dict(plugins)].index("print-site")
if print_site_position != len(plugins) - 1:

# Offset begins at 1 due to indexing starting at 0
position_offset = 1

# Check if 'hooks' is defined in the 'plugins' section
if isinstance(config.get("hooks"), dict):
position_offset += len(config.get("hooks"))

if print_site_position != len(plugins) - position_offset:
msg = "[mkdocs-print-site] 'print-site' should be defined as the *last* plugin,"
msg += "to ensure the print page has any changes other plugins make."
msg += "Please update the 'plugins:' section in your mkdocs.yml"
Expand Down

0 comments on commit cabda6f

Please sign in to comment.