-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Update shareon.js to include LinkedIn image refresh #93
Conversation
LinkedIn url has to include "&latest" so the latest url preview is being used not the cached one.
src/shareon.js
Outdated
@@ -18,7 +18,7 @@ import "./shareon.css"; | |||
*/ | |||
const urlBuilderMap = { | |||
facebook: (d) => `https://www.facebook.com/sharer/sharer.php?u=${d.url}${d.hashtags? `&hashtag=%23${d.hashtags.split('%2C')[0]}` : ''}`, | |||
linkedin: (d) => `https://www.linkedin.com/sharing/share-offsite/?url=${d.url}`, | |||
linkedin: (d) => `https://www.linkedin.com/sharing/share-offsite/?url=${d.url}${encodeURIComponent('?latest')}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you have replaced &latest
with this? Does the query parameter need to appear on the URL being shared (e.g., //shareon.js.org/?latest
) or on the final LinkedIn URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did more testing and the solution is to append the current time to the end of the url (encoded) so that LinkedIn regards it as a new url altogether and fetches the latest preview.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added ${encodeURIComponent('?' + new Date().getTime())}
Appending current time to url so that LinkedIn regards it as a new url and fetches the latest preview.
Oh, I think I now understand, what is happening here: LinkedIn caches the URL once they see it, and subsequent updates to the page (esp. its OGP tags) do not get displayed. I am sorry, but this is out of scope of Shareon. I do not want to fix the peculiarities of other social networks, especially when it requires changing the URL of the page — I will never ever do this. Thank you a lot for the great contribution, but I am afraid I can't merge it :/ |
@kytta completely understand! It is strange that it would not update it on LinkedIn's side for the same url. Thanks for considering it! For now, I am passing in from our side as a workaround (in case someone else is having the same issue like us where we are quite dependent on an updated preview image)
|
LinkedIn url has to include "&latest" so the latest url preview is being used not the cached one.