-
Notifications
You must be signed in to change notification settings - Fork 0
Home
donald-stolz edited this page Feb 19, 2021
·
4 revisions
Welcome to the socialite
wiki!
This package is meant to be used as an additional utility package within ELEVATOR's ecosystem regarding
public-facing profiles. In specific, this package exposes two main utility functions: extractUser
and buildUrl
. These functions are responsible for extracting and inserting social media usernames from raw urls.
This package offers a two-way set of functions extractUser
& buildUrl
To "extract" a username from a social media url we do the following:
import socialite from "socialite";
const rawURL = "https://www.twitter.com/myUser";
console.log(socialite.extractUser(rawURL));
The above will output myUser
;
To retrieve the absolute URL from a given username and type
(e.g., facebook, instagram, twitter), we use the buildUrl
call:
import socialite from "socialite";
const rawUsername = "myUser";
const type = "facebook"; // is an enumeration of lowercase social media domains.
console.log(socialite.buildUrl(rawUsername, type));
The above call will output https://www.facebook.com/myUser
;