Skip to content

Commit

Permalink
Update plugin.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndBondStyle authored Feb 12, 2024
1 parent 6f99fb8 commit 7c6b255
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mkdocs_glightbox/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ def on_post_page(self, output, page, config, **kwargs):
element.setAttribute('href', imgSrc);
});
"""
js_code += f"const lightbox = GLightbox({json.dumps(lb_config)});"
js_code += f"const lightbox = GLightbox({json.dumps(lb_config)});\n"
if self.using_material or "navigation.instant" in config["theme"]._vars.get(
"features", []
):
# support compatible with mkdocs-material Instant loading feature
js_code = "document$.subscribe(() => {" + js_code + "})"
js_code += "document$.subscribe(() => { lightbox.reload() });\n"
output = body_regex.sub(f"<body\\1<script>{js_code}</script></body>", output)

return output
Expand Down

0 comments on commit 7c6b255

Please sign in to comment.