@lenne.tech/ng-base 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -212,8 +212,9 @@ AuthService.ctorParameters = () => [
212
212
  */
213
213
  function apolloOptionsFactory(baseModuleConfig, httpLink, authService) {
214
214
  const links = [];
215
+ const defaultUrl = 'api.' + window.location.href + '/graphql';
215
216
  const http = httpLink.create({
216
- uri: baseModuleConfig.apiUrl,
217
+ uri: baseModuleConfig.apiUrl ? baseModuleConfig.apiUrl : 'https://' + defaultUrl,
217
218
  });
218
219
  const authMiddleware = new ApolloLink((operation, forward) => {
219
220
  const headers = {};
@@ -2310,23 +2311,79 @@ class SEOService {
2310
2311
  this.titleService = titleService;
2311
2312
  this.metaTagService = metaTagService;
2312
2313
  }
2313
- initPageForSEO(title, description, keywords) {
2314
- this.setPageTitle(title);
2315
- this.setPageDescription(description);
2316
- if (keywords) {
2317
- this.setPageKeywords(keywords);
2314
+ initPageForSEO(input) {
2315
+ this.setGeneralData(input);
2316
+ this.setTwitterData(input);
2317
+ this.setTwitterData(input);
2318
+ this.setFacebookData(input);
2319
+ if (input.keywords) {
2320
+ this.setPageKeywords(input.keywords);
2318
2321
  }
2319
2322
  }
2320
- setPageTitle(title) {
2321
- this.titleService.setTitle(title);
2322
- this.metaTagService.updateTag({ property: 'og:title', content: title });
2323
- this.metaTagService.updateTag({ name: 'twitter:title', content: title });
2323
+ /**
2324
+ * Set general metadata
2325
+ *
2326
+ * @param data
2327
+ * @private
2328
+ */
2329
+ setGeneralData(data) {
2330
+ this.titleService.setTitle(data.title);
2331
+ this.metaTagService.updateTag({ name: 'description', content: data.description });
2324
2332
  }
2325
- setPageDescription(description) {
2326
- this.metaTagService.updateTag({ name: 'description', content: description });
2327
- this.metaTagService.updateTag({ property: 'og:description', content: description });
2328
- this.metaTagService.updateTag({ name: 'twitter:description', content: description });
2333
+ /**
2334
+ * Set metadata for twitter
2335
+ *
2336
+ * @param data
2337
+ * @private
2338
+ */
2339
+ setTwitterData(data) {
2340
+ this.metaTagService.updateTag({ name: 'twitter:title', content: data.title });
2341
+ this.metaTagService.updateTag({ name: 'twitter:description', content: data.description });
2342
+ this.metaTagService.updateTag({
2343
+ property: 'twitter:url',
2344
+ content: data.url ? data.url : window.location.href,
2345
+ });
2346
+ if (data.image) {
2347
+ this.metaTagService.updateTag({
2348
+ property: 'twitter:image',
2349
+ content: data.image,
2350
+ });
2351
+ this.metaTagService.updateTag({
2352
+ property: 'twitter:card',
2353
+ content: 'summary_large_image',
2354
+ });
2355
+ }
2329
2356
  }
2357
+ /**
2358
+ * Set metadata for facebook
2359
+ *
2360
+ * @param data
2361
+ * @private
2362
+ */
2363
+ setFacebookData(data) {
2364
+ this.metaTagService.updateTag({ property: 'og:title', content: data.title });
2365
+ this.metaTagService.updateTag({ property: 'og:description', content: data.description });
2366
+ this.metaTagService.updateTag({
2367
+ property: 'og:type',
2368
+ content: 'website',
2369
+ });
2370
+ this.metaTagService.updateTag({
2371
+ property: 'og:url',
2372
+ content: data.url ? data.url : window.location.href,
2373
+ });
2374
+ if (data.image) {
2375
+ this.metaTagService.updateTag({
2376
+ property: 'og:image',
2377
+ content: data.image,
2378
+ });
2379
+ }
2380
+ }
2381
+ /**
2382
+ * Set page keywords
2383
+ *
2384
+ * @param keywords
2385
+ * @private
2386
+ */
2330
2387
  setPageKeywords(keywords) {
2331
2388
  this.metaTagService.updateTag({ name: 'keywords', content: keywords });
2332
2389
  }