Skip to content

Commit

Permalink
add hooks to position offset plugin check
Browse files Browse the repository at this point in the history
  • Loading branch information
BartvanWoesik committed Sep 11, 2024
1 parent 7e218f2 commit 4df248b
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 4df248b

Please sign in to comment.