@rededor/site-front-end-lib 0.0.2 → 0.0.3-alpha.0

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.
Files changed (39) hide show
  1. package/esm2022/lib/helpers/getSiteUrl.func.mjs +11 -0
  2. package/esm2022/lib/helpers/index.mjs +4 -1
  3. package/esm2022/lib/helpers/removeHtmlTags.func.mjs +6 -0
  4. package/esm2022/lib/models/breadcrumb/breadcrumb-item.model.mjs +2 -0
  5. package/esm2022/lib/models/breadcrumb/breadcrumb-json-item.model.mjs +2 -0
  6. package/esm2022/lib/models/rdsl-post-category.model.mjs +2 -0
  7. package/esm2022/lib/models/seo/seo-data.model.mjs +2 -0
  8. package/esm2022/lib/models/seo/seo-unidade.model.mjs +2 -0
  9. package/esm2022/lib/models/social-meta-properties.model.mjs +2 -0
  10. package/esm2022/lib/models/wordpress/category/wpCategory.model.mjs +2 -0
  11. package/esm2022/lib/models/wordpress/post/post.model.mjs +2 -0
  12. package/esm2022/lib/services/index.mjs +3 -1
  13. package/esm2022/lib/services/log/log.service.mjs +3 -8
  14. package/esm2022/lib/services/seo/seo.service.mjs +469 -0
  15. package/esm2022/lib/services/server-response/server-response.service.mjs +86 -0
  16. package/esm2022/lib/tokens/LibConfig.mjs +1 -1
  17. package/esm2022/lib/tokens/express.tokens.mjs +4 -0
  18. package/esm2022/public-api.mjs +2 -1
  19. package/fesm2022/rededor-site-front-end-lib.mjs +590 -32
  20. package/fesm2022/rededor-site-front-end-lib.mjs.map +1 -1
  21. package/lib/helpers/getSiteUrl.func.d.ts +2 -0
  22. package/lib/helpers/index.d.ts +3 -0
  23. package/lib/helpers/removeHtmlTags.func.d.ts +2 -0
  24. package/lib/models/breadcrumb/breadcrumb-item.model.d.ts +6 -0
  25. package/lib/models/breadcrumb/breadcrumb-json-item.model.d.ts +8 -0
  26. package/lib/models/rdsl-post-category.model.d.ts +8 -0
  27. package/lib/models/seo/seo-data.model.d.ts +9 -0
  28. package/lib/models/seo/seo-unidade.model.d.ts +6 -0
  29. package/lib/models/social-meta-properties.model.d.ts +9 -0
  30. package/lib/models/wordpress/category/wpCategory.model.d.ts +14 -0
  31. package/lib/models/wordpress/post/post.model.d.ts +33 -0
  32. package/lib/services/index.d.ts +2 -0
  33. package/lib/services/log/log.service.d.ts +0 -1
  34. package/lib/services/seo/seo.service.d.ts +140 -0
  35. package/lib/services/server-response/server-response.service.d.ts +31 -0
  36. package/lib/tokens/LibConfig.d.ts +3 -0
  37. package/lib/tokens/express.tokens.d.ts +4 -0
  38. package/package.json +3 -1
  39. package/public-api.d.ts +1 -0
@@ -0,0 +1,8 @@
1
+ export interface RdslPostCategory {
2
+ id?: number;
3
+ name: string;
4
+ slug?: string;
5
+ highlightColor?: string;
6
+ textColor?: string;
7
+ themeColor?: string;
8
+ }
@@ -0,0 +1,9 @@
1
+ export interface SeoData {
2
+ title: {
3
+ text: string;
4
+ sub?: boolean;
5
+ };
6
+ description: any;
7
+ canonical?: string;
8
+ socialTags?: any;
9
+ }
@@ -0,0 +1,6 @@
1
+ export interface SeoUnidade {
2
+ unidade: any;
3
+ unidadeName: string;
4
+ unidadePath: string;
5
+ unidadeSlug: string;
6
+ }
@@ -0,0 +1,9 @@
1
+ export interface SocialMetaProperties {
2
+ title?: string;
3
+ url?: string;
4
+ type?: string;
5
+ description?: string;
6
+ image?: string;
7
+ twitterCard?: string;
8
+ twitterSite?: string;
9
+ }
@@ -0,0 +1,14 @@
1
+ import { WpGlobalResponse, WpYoastResponse } from '../WpResponse.model';
2
+ export interface WpCategory<T = any> extends WpGlobalResponse, Omit<WpYoastResponse, 'yoast_data'> {
3
+ id: number;
4
+ count: number;
5
+ description: string;
6
+ link: string;
7
+ name: string;
8
+ slug: string;
9
+ taxonomy: string;
10
+ parent: number;
11
+ meta: any;
12
+ acf?: T;
13
+ [propName: string]: any;
14
+ }
@@ -0,0 +1,33 @@
1
+ import { RdslPostCategory } from "../../rdsl-post-category.model";
2
+ import { WpCategory } from "../category/wpCategory.model";
3
+ import { WpCommonResponse, WpGlobalResponse, WpPublishingResponse, WpYoastResponse } from "../WpResponse.model";
4
+ export interface WpPost<T = any> extends WpCommonResponse<T>, WpGlobalResponse, WpPublishingResponse, WpYoastResponse {
5
+ author: number;
6
+ comment_status: string;
7
+ ping_status: string;
8
+ sticky: boolean;
9
+ format: string;
10
+ meta: any;
11
+ categories: number[];
12
+ tags: string[];
13
+ featured_media_path: string;
14
+ body?: WpPost[];
15
+ headers?: {
16
+ "X-WP-Total"?: number;
17
+ "X-WP-TotalPages": number;
18
+ };
19
+ rdslMainCategory?: RdslPostCategory;
20
+ downloadItemCategories: WpCategory[];
21
+ }
22
+ export interface WpCustomPost<T = any> extends WpCommonResponse<T>, WpGlobalResponse, WpPublishingResponse, WpYoastResponse {
23
+ author?: number;
24
+ comment_status?: string;
25
+ ping_status?: string;
26
+ sticky?: boolean;
27
+ format?: string;
28
+ categories?: number[];
29
+ tags?: string[];
30
+ acf?: T;
31
+ featured_media_path?: string;
32
+ [attr: string]: any;
33
+ }
@@ -4,5 +4,7 @@ export * from './http-client/http-client.service';
4
4
  export * from './log/log.service';
5
5
  export * from './ngu-carousel/ngu-carousel.service';
6
6
  export * from './site-back-end/site-back-end.service';
7
+ export * from './seo/seo.service';
8
+ export * from './server-response/server-response.service';
7
9
  export * from './ssr-loading/ssr-loading.service';
8
10
  export * from './transfer-state/transfer-state.service';
@@ -9,7 +9,6 @@ export declare class LogService {
9
9
  logMsg(msg: any, label?: string): void;
10
10
  logLoad(component?: string): void;
11
11
  log404(component?: string): void;
12
- private getSiteUrl;
13
12
  getPageURL(): string;
14
13
  static ɵfac: i0.ɵɵFactoryDeclaration<LogService, never>;
15
14
  static ɵprov: i0.ɵɵInjectableDeclaration<LogService>;
@@ -0,0 +1,140 @@
1
+ import { Meta, Title } from '@angular/platform-browser';
2
+ import { Location } from '@angular/common';
3
+ import { SocialMetaProperties } from '../../models/social-meta-properties.model';
4
+ import { BreadcrumbItem } from '../../models/breadcrumb/breadcrumb-item.model';
5
+ import { SeoData } from '../../models/seo/seo-data.model';
6
+ import { SeoUnidade } from '../../models/seo/seo-unidade.model';
7
+ import { WpPost } from '../../models/wordpress/post/post.model';
8
+ import { LibConfig } from '../../tokens/LibConfig';
9
+ import * as i0 from "@angular/core";
10
+ export declare class SeoService {
11
+ private title;
12
+ private meta;
13
+ private location;
14
+ private libConfig;
15
+ private document;
16
+ separator: string;
17
+ defaultTitle: string;
18
+ activeDescription: string;
19
+ sameAs: string[];
20
+ twitterUser: string;
21
+ private canonicalTag;
22
+ private jsonTag;
23
+ private jsonTagId;
24
+ private breadcrumbsJsonTag;
25
+ private breadcrumbsJsonTagId;
26
+ unidade: any;
27
+ unidadeName: string;
28
+ unidadePath: string;
29
+ unidadeSlug: string;
30
+ constructor(title: Title, meta: Meta, location: Location, libConfig: LibConfig, document: Document);
31
+ setFullSeo(data: SeoData): void;
32
+ /**
33
+ * Define tag description da página
34
+ * @param content conteúdo da descrição <string>
35
+ */
36
+ setDescription(content: string): SeoService;
37
+ /**
38
+ * Define meta tags para a página
39
+ * @param tag nome da tag meta
40
+ * @param content conteúdo da tag meta
41
+ * @param type tipo de tag meta
42
+ */
43
+ setMetaTag(tag: string, content: string, type?: string): this;
44
+ /**
45
+ * Remove meta tags da página
46
+ * @param tag nome da tag meta
47
+ * @param content conteúdo da tag meta
48
+ * @param attr atributo da tag meta
49
+ * @param type tipo de tag meta
50
+ */
51
+ removeTag(tag: string, content: string, attr: string, type?: string): this;
52
+ /**
53
+ * Define meta tags para Facebook
54
+ * @param title título para o facebook
55
+ * @param description descrição para o facebook
56
+ * @param url url para definição do facebook
57
+ * @param img imagem para definição no facebook
58
+ */
59
+ setMetaFacebook(title: string, description: string, url: string, img?: string | null): void;
60
+ /**
61
+ * Define meta tags para Twitter
62
+ * @param title título para o twitter
63
+ * @param description descrição para o twitter
64
+ * @param url url para o twitter
65
+ * @param img imagem para definição no twitter
66
+ */
67
+ setMetaTwitter(title: string, description: string, url: string, img?: string | null): void;
68
+ /**
69
+ * Define tags de redes sociais (Twitter e Open Graph)
70
+ * @param properties
71
+ */
72
+ setSocialTags(properties?: SocialMetaProperties): this;
73
+ /**
74
+ * Define título da página
75
+ * @param title título da página <string>
76
+ * @param sub Se é subsite acrescenta unidade <boolean>
77
+ */
78
+ setTitle(title: string, sub?: boolean): this;
79
+ /** Obtem título atual da página */
80
+ getTitle(): string;
81
+ set404Title(component?: string): this;
82
+ /** Cria tag script para JSON de breadcrumbs */
83
+ private createBreadcrumbsJSONTag;
84
+ /** Retorna tag para script json de breadcrumbs ou cria se não houver. */
85
+ private getBreadcrumbsJSONTag;
86
+ /** Define o JSON de breadcrumbs da página */
87
+ setBreadcrumbsJson(items: BreadcrumbItem[]): this;
88
+ /** Converte itens do breadcrumb em itens do JSON */
89
+ private getJsonBreadcrumbItems;
90
+ /**
91
+ * Monta a url do item de breadcrumb proveniente do array de urls
92
+ * ou do caminho da própria página, conforme caso do último item.
93
+ */
94
+ private getBreadcrumbItemUrl;
95
+ /** Cria tag script para o JSON de SEO */
96
+ private createJSONTag;
97
+ /** Retorna tag para script json de breadcrumbs ou cria se não houver. */
98
+ private getJSONTag;
99
+ /** Define JSON para SEO somente quando no servidor */
100
+ setPageJson(): this;
101
+ /** Obtem JSON da Organização */
102
+ private getOrgJson;
103
+ /** Obtem JSON do Website (portal, unidades, etc) */
104
+ private getWebsiteJson;
105
+ /** Obtem Json da página */
106
+ private getWebpageJson;
107
+ private getUnidadePath;
108
+ /**
109
+ * Obtém a URL canônica da página.
110
+ * @returns A URL canônica da página.
111
+ */
112
+ getCanonicalHref(): string;
113
+ /** Cria tag para links canonicals no head */
114
+ private createCanonicalTag;
115
+ /** Retorna tag para link canonical existe ou cria se não houver. */
116
+ private getCanonicalTag;
117
+ /**
118
+ * Define link canonical da página
119
+ * @param url url canonical
120
+ */
121
+ setCanonicalHref(url?: string): this;
122
+ /**
123
+ * Verifica se a URL fornecida é um link canonical personalizado
124
+ * @param url URL fornecida
125
+ */
126
+ private isCustomCanonical;
127
+ /**
128
+ * Obtém uma url válida na aplicação proveniente de uma URL gerada
129
+ * pelo plugin Yoast para canonical automático.
130
+ * Ex.: https://wp.rededorsaoluiz.com.br/brasil/especialidades/cardiologia/
131
+ * @param urlFromWpApi URL canonica gerada pelo Yoast Plugin.
132
+ */
133
+ toLocalCanonical(urlFromWpApi: string): string;
134
+ getPostContent(post: WpPost): string;
135
+ addArticleScript(post: WpPost, scriptName: string): void;
136
+ removeArticleScript(scriptName: string): void;
137
+ setUnidade({ unidade, unidadeName, unidadePath, unidadeSlug, }: SeoUnidade): void;
138
+ static ɵfac: i0.ɵɵFactoryDeclaration<SeoService, never>;
139
+ static ɵprov: i0.ɵɵInjectableDeclaration<SeoService>;
140
+ }
@@ -0,0 +1,31 @@
1
+ import * as i0 from "@angular/core";
2
+ export interface IServerResponseService {
3
+ getHeader(key: string): string;
4
+ setHeader(key: string, value: string): this;
5
+ setHeaders(dictionary: {
6
+ [key: string]: string;
7
+ }): this;
8
+ appendHeader(key: string, value: string, delimiter?: string): this;
9
+ setStatus(code: number, message?: string): this;
10
+ setNotFound(message?: string): this;
11
+ setError(message?: string): this;
12
+ setRedirect(message?: string): this;
13
+ }
14
+ export declare class ServerResponseService implements IServerResponseService {
15
+ private response;
16
+ constructor(response: any);
17
+ getHeader(key: string): string;
18
+ setHeader(key: string, value: string): this;
19
+ appendHeader(key: string, value: string, delimiter?: string): this;
20
+ setHeaders(dictionary: {
21
+ [key: string]: string;
22
+ }): this;
23
+ setStatus(code: number, message?: string): this;
24
+ setNotFound(message?: string): this;
25
+ setUnauthorized(message?: string): this;
26
+ setError(message?: string): this;
27
+ setRedirect(message?: string): this;
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<ServerResponseService, [{ optional: true; }]>;
29
+ static ɵprov: i0.ɵɵInjectableDeclaration<ServerResponseService>;
30
+ }
31
+ export type HttpCacheDirective = 'public' | 'private' | 'no-store' | 'no-cache' | 'must-revalidate' | 'no-transform' | 'proxy-revalidate';
@@ -2,6 +2,7 @@ import { InjectionToken } from "@angular/core";
2
2
  export interface LibConfig {
3
3
  production: boolean;
4
4
  server: boolean;
5
+ siteName: string;
5
6
  siteUrl: string;
6
7
  siteSufix?: string;
7
8
  client_id: string;
@@ -21,5 +22,7 @@ export interface LibConfig {
21
22
  id: string;
22
23
  key: string;
23
24
  };
25
+ wpUrl: string;
26
+ keywords: string;
24
27
  }
25
28
  export declare const LIB_CONFIG: InjectionToken<LibConfig>;
@@ -0,0 +1,4 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { Request, Response } from 'express';
3
+ export declare const REQUEST: InjectionToken<Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>>;
4
+ export declare const RESPONSE: InjectionToken<Response<any, Record<string, any>>>;
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@rededor/site-front-end-lib",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-alpha.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^17.3.0",
6
6
  "@angular/core": "^17.3.0",
7
7
  "@ngu/carousel": "^9.0.0",
8
8
  "@rededor/cura": "^0.5.1",
9
9
  "algoliasearch": "^4.16.0",
10
+ "express": "^4.18.2",
11
+ "he": "^1.2.0",
10
12
  "ngx-device-detector": "^7.0.0"
11
13
  },
12
14
  "publishConfig": {
package/public-api.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './lib/enums/Estados.enum';
5
5
  export * from './lib/enums/EnumDoencaTaxonomy.enum';
6
6
  export * from './lib/enums/IconCuraDefaultType.enum';
7
7
  export * from './lib/tokens/CuraApi';
8
+ export * from './lib/tokens/express.tokens';
8
9
  export * from './lib/tokens/LibConfig';