2020-11-04 18:01:04 +00:00
|
|
|
import * as plugins from './websetup.plugins';
|
|
|
|
import * as interfaces from './interfaces';
|
|
|
|
|
2020-11-04 18:09:07 +00:00
|
|
|
import { Tag } from './websetup.classes.tag';
|
2020-11-04 18:01:04 +00:00
|
|
|
|
|
|
|
export class JsonLdTag extends Tag {
|
|
|
|
public static createCompanyLd(companyDataArg: plugins.tsclass.business.ICompany) {
|
|
|
|
// lets care about linked data
|
|
|
|
const companyLd = {
|
|
|
|
'@context': 'https://schema.org',
|
|
|
|
'@type': 'Corporation',
|
|
|
|
name: companyDataArg.name,
|
|
|
|
alternateName: companyDataArg.name.replace(' GmbH', ''),
|
|
|
|
url: companyDataArg.contact.website,
|
|
|
|
logo: companyDataArg.contact.logoUrl,
|
|
|
|
contactPoint: {
|
|
|
|
'@type': 'ContactPoint',
|
|
|
|
telephone: companyDataArg.contact.phone,
|
|
|
|
contactType: 'customer service',
|
|
|
|
areaServed: 'DE',
|
|
|
|
availableLanguage: ['en', 'German'],
|
|
|
|
},
|
|
|
|
sameAs: [],
|
|
|
|
};
|
2020-11-04 18:09:07 +00:00
|
|
|
|
2020-11-04 18:01:04 +00:00
|
|
|
if (companyDataArg.contact.facebookUrl) {
|
|
|
|
companyLd.sameAs.push(companyDataArg.contact.facebookUrl);
|
|
|
|
}
|
2020-11-04 18:09:07 +00:00
|
|
|
|
2020-11-04 18:01:04 +00:00
|
|
|
if (companyDataArg.contact.twitterUrl) {
|
|
|
|
companyLd.sameAs.push(companyDataArg.contact.twitterUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
const ldTag = new JsonLdTag(companyLd);
|
|
|
|
return ldTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(ldObjectArg: any) {
|
|
|
|
super();
|
|
|
|
const jsonLdElement = document.createElement('script');
|
|
|
|
jsonLdElement.type = 'application/ld+json';
|
|
|
|
jsonLdElement.text = JSON.stringify(JSON.stringify(ldObjectArg));
|
|
|
|
this.elementRef = jsonLdElement;
|
|
|
|
}
|
2020-11-04 18:09:07 +00:00
|
|
|
}
|