kytta / shareon

📯 Lightweight, stylish, and ethical share buttons for popular social networks
https://shareon.js.org/
MIT License
464 stars 23 forks source link

Update shareon.js to include LinkedIn image refresh #93

Closed lisaschumann closed 10 months ago

lisaschumann commented 11 months ago

LinkedIn url has to include "&latest" so the latest url preview is being used not the cached one.

kytta commented 10 months ago

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.

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 :/

lisaschumann commented 10 months ago

@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)

const currentTime = new Date().getTime();
const shareUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://domain.com/' + '?' + currentTime)}`