-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use this libraries on cdn or other way, instead npm install #36
Comments
@bosemian Yes, that shouldn't be a problem. |
@enesser Great, but I can not see this libraries on https://cdnjs.com/libraries. |
Yesss. CDN support please! |
@enesser Any update ? |
Does https://unpkg.com/browse/[email protected]/index.js work for any of y'all? |
I think this is the correct url to use: https://unpkg.com/[email protected]/index.js but I can't figure out how to actually use that inside my Vue component |
@vesper8 I ended up rolling my own solution, not exactly proud of it but it works. It lives in a composable and gets called via a interface Profile {
id: string;
address: string;
email: string;
firstName: string;
lastName: string;
title: string;
titleEn: string;
phoneCell?: string;
phoneWork?: string;
profilePicture?: string;
expand: {
works_at: {
street: string;
city: string;
country: string;
};
works_in: {
id: string;
name: string;
};
};
}
const makeVCardInfo = (info: string) => `N:${info}\r\n`;
const makeVCardName = (name: string) => `FN:${name}\r\n`;
const makeVCardOrg = (org: string) => `ORG:${org}\r\n`;
const makeVCardTitle = (title: string) => `TITLE:${title}\r\n`;
const makeVCardTel = (type: string, number: string | undefined) =>
number && `TEL;TYPE=${type}:${number}\r\n`;
const makeVCardAdr = (address: string) => `ADR;TYPE=WORK,PREF:;;${address}\r\n`;
const makeVCardEmail = (email: string) => `EMAIL:${email}\r\n`;
const makeVCardTimeStamp = () => `REV:${new Date().toISOString()}\r\n`;
export default function (profile: Profile) {
const vcard =
"BEGIN:VCARD\r\nVERSION:3.0\r\n" +
makeVCardInfo(`${profile.lastName};${profile.firstName};`) +
makeVCardName(`${profile.firstName} ${profile.lastName}`) +
makeVCardOrg(profile.expand.works_in.name) +
makeVCardTitle(profile.title) +
makeVCardAdr(
`${profile.expand.works_at.street}, ${profile.expand.works_at.city}, ${profile.expand.works_at.country}`
) +
makeVCardEmail(profile.email) +
makeVCardTel("WORK", profile.phoneWork) +
makeVCardTel("CELL", profile.phoneCell) +
makeVCardTimeStamp() +
"END:VCARD";
const a = document.createElement("a");
const file = new Blob([vcard], { type: "text/vcard" });
const sanitizedName = sanitizeName(profile.firstName, profile.lastName);
a.href = URL.createObjectURL(file);
a.download = `vcard-${sanitizedName}.vcf`;
a.click();
URL.revokeObjectURL(a.href);
} |
Hi enesser, my project is very small. I don't create that via npm, So I can use this vCards-js on CDN ?,
Thank you :)
The text was updated successfully, but these errors were encountered: