web-social-share
Version:
A Web Component to share urls and text on social networks
17 lines (16 loc) • 622 B
JavaScript
import { openNewWindow, shareEncodedUrl } from "../utils/utils";
export const reddit = async ({ socialShareSubreddit, socialShareUrl, socialShareText, openWindowTarget: target }) => {
let urlString = 'https://www.reddit.com/';
if (socialShareSubreddit) {
urlString += 'r/' + socialShareSubreddit + '/submit?url=';
}
else {
urlString += 'submit?url=';
}
urlString += shareEncodedUrl(socialShareUrl);
if (socialShareText) {
urlString += `&title=${encodeURIComponent(socialShareText)}`;
}
openNewWindow({ urlString, target });
};
//# sourceMappingURL=reddit.js.map