File: /var/www/quadcode-site/src/js/components/news/share.js
export const share = () => {
const container = document.querySelectorAll('.share');
if (container.length) {
container.forEach(item => {
const shareButton = item.querySelectorAll('.share__link');
if (shareButton.length) {
shareButton.forEach(btn => {
if (btn.dataset.social) {
switch (btn.dataset.social) {
case 'telegram':
btn.href = `https://t.me/share/url?url=${window.location.href}`;
break;
case 'twitter':
btn.href = `https://twitter.com/intent/tweet?url=${window.location.href}`;
break;
case 'facebook':
btn.href = `https://www.facebook.com/sharer.php?u=${window.location.href}`;
break;
case 'whatapp':
btn.href = `whatsapp://send/?text=''%20${window.location.href}`;
break;
}
}
});
}
});
}
}