Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Support for Query Parameters in Hash plugin #1673

Open
BenAlanSouthall opened this issue Nov 15, 2024 · 0 comments
Open

FR: Support for Query Parameters in Hash plugin #1673

BenAlanSouthall opened this issue Nov 15, 2024 · 0 comments

Comments

@BenAlanSouthall
Copy link

Summary

The hash plugin is a very nice feature. I'd like to be able to change query arguments in the URL, instead of just the hash-location, so that I have a unique URL I can filter on later.

Basic example

I guess the most flexible way of implementing this might be some sort of template I can provide in the options for the hash plugin. Perhaps a callback function that receives the gallery and slide numbers and generates the URL, or a string template that will be interpolated. Not a JS developer so there may be more idiomatic ways.

Motivation

I host my site statically. I'd like to use the images in the gallery as og:image links for social media, and I'd also like for the user to be able to share either by copying the URL the old-fashioned way (like I normally do ;) ) and using share buttons - so I want to rely on using the URL, rather than the custom content for the sharing URL that opens in a new tab with the share plugin. This way, if someone just copies a link to the page when one of the images in the gallery is open, I can have the social card rendered properly for that image when they paste it into some platform and write a post.

I can use some server-side routing to detect the scraper's user-agent and filter those out to return a short page containing the og:image tag for just that image, without displaying the main page. However, the social media scrapers appear to strip the document location from the URL when they go to collect the page info and generate the preview.

Therefore, if I can change the query argument on the page, I have a unique URL that the scrapers will use, and can redirect them to the given social card image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant