web-social-share
Version:
A Web Component to share urls and text on social networks
15 lines (14 loc) • 619 B
JavaScript
import { isMobile, openNewWindow, shareEncodedUrl } from "../utils/utils";
export const whatsapp = async ({ socialShareText, socialShareUrl, openWindowTarget: target }) => {
const mobile = isMobile();
let urlString = mobile
? 'https://api.whatsapp.com/send?text='
: 'https://web.whatsapp.com/send?text=';
if (socialShareText) {
urlString += encodeURIComponent(socialShareText) + '%0A';
}
//default to the current page if a URL isn't specified
urlString += shareEncodedUrl(socialShareUrl);
openNewWindow({ urlString, target });
};
//# sourceMappingURL=whatsapp.js.map