Skip to content

Commit

Permalink
Added support for disabling glightbox with image class or page meta (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed Aug 10, 2022
1 parent f4e1274 commit 54672c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mkdocs-glightbox-0.2.0 (2022-08-10)

* Added support for disabling glightbox with image class or page meta (#2)

mkdocs-glightbox-0.1.7 (2022-07-26)

* Fix #1: Ignore Emojis
Expand All @@ -18,4 +22,4 @@ mkdocs-glightbox-0.1.4 (2022-06-12)

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

* first release
* First release
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ A MkDocs plugin supports image lightbox with [GLightbox](https://github.com/biat

GLightbox is a pure javascript lightbox library with mobile support.

[Live demo](https://blueswen.github.io/mkdocs-glightbox/) with [mkdocs-material](https://squidfunk.github.io/mkdocs-material/) theme.
[Live demo](https://blueswen.github.io/mkdocs-glightbox/) with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/).

## Dependency

1. Python Package
1. beautifulsoup4==4.11.1
1. beautifulsoup4>=4.11.1
2. GLightbox javascript file and css file
1. GLightbox==3.2.0

Expand All @@ -24,7 +24,7 @@ GLightbox is a pure javascript lightbox library with mobile support.
pip install mkdocs-glightbox
```

2. Add ```glightbox``` plugin in to your mkdocs.yml plugins sections:
2. Add ```glightbox``` plugin to your mkdocs.yml plugins sections:

```yaml
plugins:
Expand Down Expand Up @@ -57,6 +57,8 @@ GLightbox is a pure javascript lightbox library with mobile support.

Check more options information on [GLightbox Docs](https://github.com/biati-digital/glightbox#lightbox-options).

4. For more flexibility, you can disable lightbox by a [specific image](https://blueswen.github.io/mkdocs-glightbox/disable/image.md) or a [specific page](https://blueswen.github.io/mkdocs-glightbox/disable/page.md).

## License

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/Blueswen/mkdocs-glightbox/blob/main/LICENSE) file for details.
5 changes: 5 additions & 0 deletions mkdocs_glightbox/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ def on_post_page(self, output, page, config, **kwargs):

def on_page_content(self, html, page, config, **kwargs):
""" Wrap img tag with archive tag with glightbox class and attributes from config """
# skip page with meta glightbox is false
if "glightbox" in page.meta and page.meta.get('glightbox', True) is False:
return html
# skip emoji img with index as class name from pymdownx.emoji https://facelessuser.github.io/pymdown-extensions/extensions/emoji/
skip_class = ["emojione", "twemoji", "gemoji"]
# skip image with off-glb class
skip_class += ["off-glb"]
soup = BeautifulSoup(html, "html.parser")
imgs = soup.find_all("img")
for img in imgs:
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.7",
version="0.2.0",
author="Blueswen",
author_email="[email protected]",
url = "https://blueswen.github.io/mkdocs-glightbox",
Expand Down

0 comments on commit 54672c5

Please sign in to comment.