Skip to content

Commit

Permalink
v0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed Jul 16, 2022
1 parent 3d7d2c5 commit 0091a19
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mkdocs-glightbox-0.1.5 (2022-07-16)

* Fix mkdocs-material header + sidebar vanishing issue when open lightbox (Inspired from https://github.com/biati-digital/glightbox/issues/22)
* Fix mkdocs-material content shrinking causing footer offset issue when open lightbox
* Support compatible with mkdocs-material Instant loading feature

mkdocs-glightbox-0.1.4 (2022-06-12)

* Fix assets location bug

mkdocs-glightbox-0.1.3 (2022-06-10)

* first release
45 changes: 26 additions & 19 deletions mkdocs_glightbox/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,35 @@ def on_post_page(self, output, page, config, **kwargs):
""" Add css link tag, javascript script tag, and javascript code to initialize GLightbox """

soup = BeautifulSoup(output, "html.parser")

if soup.head:
css_link = soup.new_tag("link")
css_link.attrs["href"] = utils.get_relative_url(
utils.normalize_url("assets/stylesheets/glightbox.min.css"),
page.url
)
css_link.attrs["rel"] = "stylesheet"
soup.head.append(css_link)

css_link = soup.new_tag("link")
css_link.attrs["href"] = utils.get_relative_url(
utils.normalize_url("assets/stylesheets/glightbox.min.css"),
page.url
)
css_link.attrs["rel"] = "stylesheet"
soup.head.append(css_link)
css_patch = soup.new_tag("style")
css_patch.string = "html.glightbox-open { overflow: initial; height: 100%; }"
soup.head.append(css_patch)

js_script = soup.new_tag("script")
js_script.attrs["src"] = utils.get_relative_url(
utils.normalize_url("assets/javascripts/glightbox.min.js"),
page.url
)
soup.head.append(js_script)
js_script = soup.new_tag("script")
js_script.attrs["src"] = utils.get_relative_url(
utils.normalize_url("assets/javascripts/glightbox.min.js"),
page.url
)
soup.head.append(js_script)

js_code = soup.new_tag("script")
js_code["type"] = "text/javascript"
lb_config = dict(self.config)
lb_config = {k: lb_config[k] for k in ["touchNavigation", "loop"]}
js_code.string = f"const lightbox = GLightbox({json.dumps(lb_config)});"
soup.body.append(js_code)
js_code = soup.new_tag("script")
lb_config = dict(self.config)
lb_config = {k: lb_config[k] for k in ["touchNavigation", "loop"]}
js_code.string = f"const lightbox = GLightbox({json.dumps(lb_config)});"
if config["theme"].name == "material" or "navigation.instant" in config["theme"]._vars.get("features", []):
# support compatible with mkdocs-material Instant loading feature
js_code.string = "document$.subscribe(() => {" + js_code.string + "})"
soup.body.append(js_code)

return str(soup)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="mkdocs-glightbox",
version="0.1.4",
version="0.1.5",
author="Blueswen",
author_email="blueswen.tw@gmail.com",
url = "https://blueswen.github.io/mkdocs-glightbox",
Expand Down

0 comments on commit 0091a19

Please sign in to comment.