Neoteroi / mkdocs-plugins

Plugins for MkDocs.
MIT License
116 stars 9 forks source link

Workaround for lightbox #31

Closed jon-harper closed 1 year ago

jon-harper commented 1 year ago

Lightbox will handily ruin any cards that have a url attribute. It moves the link from a parent element to an empty sibling; marking any child images with the skip-lightbox class fixes this.

markdown/image.py: I added a variable to the build_image_html method to add this class to the image. It defaults to False, so it won't break existing code.

cards/html.py: If the card has a URL, each build_image_html call asks for the skip-lightbox class in the html.

Hope this is helpful!

Edit: I fixed an issue where item.url being None wasn't caught.

RobertoPrevato commented 1 year ago

Hi @jon-harper Sorry for not replying earlier to your PR - when I saw this PR at the beginning of January I was busy and then I forgot completely to follow up... 🤦🏼

I am not convinced that addnig features that are specific to a JavaScript library is a good idea. I prefer to keep the library agnostic of third-party JavaScript libraries. The cards plugin already supports adding specific id and class to the parent of the images, isn't it sufficient to exclude the selector of this library? I looked into the documentation of GLightbox and couldn´t find anything about the skip-lightbox class mentioned in the code of the PR.

jon-harper commented 1 year ago

Sorry for not replying earlier to your PR - when I saw this PR at the beginning of January I was busy and then I forgot completely to follow up... 🤦🏼

You're good! I completely forgot about it. I sent a short bit about it on Mastodon but promptly stopped using the platform, as well.

I am not convinced that addnig features that are specific to a JavaScript library is a good idea. I prefer to keep the library agnostic of third-party JavaScript libraries. The cards plugin already supports adding specific id and class to the parent of the images, isn't it sufficient to exclude the selector of this library?

You are quite right; that's one reason my brain kinda dropped off thinking about this.

I looked into the documentation of GLightbox and couldn´t find anything about the skip-lightbox class mentioned in the code of the PR.

I just visited and it looks like they completely redid the docs for the project. That's possibly an oversight on the documentation writer's part.

Anyway, since this definitely doesn't do anything new, I'll close it.