@dotcms/angular 0.0.1-alpha.44 → 0.0.1-alpha.46

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 (2) hide show
  1. package/README.md +76 -30
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @dotcms/angular
2
2
 
3
- `@dotcms/angular` is the official Angular library designed to work seamlessly with dotCMS. This library simplifies the process of rendering dotCMS pages and integrating with the [Universal Visual Editor](dotcms.com/docs/latest/universal-visual-editor) in your Angular applications.
3
+ `@dotcms/angular` is the official Angular library designed to work seamlessly with dotCMS. This library simplifies the process of rendering dotCMS pages and integrating with the [Universal Visual Editor](https://www.dotcms.com/docs/latest/universal-visual-editor) in your Angular applications.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  ## Features
20
20
 
21
- - A set of Angular components developer for dotCMS page rendering and editor integration.
21
+ - A set of Angular components developed for dotCMS page rendering and editor integration.
22
22
  - Enhanced development workflow with full TypeScript support.
23
23
  - Optimized performance for efficient rendering of dotCMS pages in Angular applications.
24
24
  - Flexible customization options to adapt to various project requirements.
@@ -37,7 +37,7 @@ Or using Yarn:
37
37
  yarn add @dotcms/angular
38
38
  ```
39
39
 
40
- ## Configutarion
40
+ ## Configuration
41
41
  ### Provider Setup
42
42
  We need to provide the information of our dotCMS instance
43
43
 
@@ -51,10 +51,11 @@ const DOTCMS_CLIENT_CONFIG: ClientConfig = {
51
51
  siteId: environment.siteId
52
52
  };
53
53
  ```
54
- And add this config in the Angular app ApplicationConfig.
54
+
55
+ Add this configuration to `ApplicationConfig` in your Angular app.
55
56
 
56
57
  `src/app/app.config.ts`
57
- ```javascript
58
+ ```typescript
58
59
  import { InjectionToken } from '@angular/core';
59
60
  import { ClientConfig, DotCmsClient } from '@dotcms/client';
60
61
 
@@ -70,36 +71,40 @@ export const appConfig: ApplicationConfig = {
70
71
  ],
71
72
  };
72
73
  ```
74
+
73
75
  This way, we will have access to `DOTCMS_CLIENT_TOKEN` from anywhere in our application.
74
76
 
75
77
  ### Client Usage
76
78
  To interact with the client and obtain information from, for example, our pages
77
79
 
78
- ```javascript
79
- private readonly client = inject(DOTCMS_CLIENT_TOKEN);
80
-
81
- this.client.page
82
- .get({ ...pageParams })
83
- .then((response) => {
84
- // Use your response
85
- })
86
- .catch((e) => {
87
- const error: PageError = {
88
- message: e.message,
89
- status: e.status,
90
- };
91
- // Use the error response
92
- })
80
+ ```typescript
81
+ export class YourComponent {
82
+ private readonly client = inject(DOTCMS_CLIENT_TOKEN);
83
+
84
+ this.client.page
85
+ .get({ ...pageParams })
86
+ .then((response) => {
87
+ // Use your response
88
+ })
89
+ .catch((e) => {
90
+ const error: PageError = {
91
+ message: e.message,
92
+ status: e.status,
93
+ };
94
+ // Use the error response
95
+ })
96
+ }
93
97
  ```
94
- For more information to how to use DotCms Client, you can visit the [documentation](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/client/README.md)
98
+
99
+ For more information on how to use the dotCMS Client, you can visit the [documentation](https://www.github.com/dotCMS/core/blob/main/core-web/libs/sdk/client/README.md)
95
100
 
96
101
  ## DotCMS Page API
97
102
 
98
103
  The `DotcmsLayoutComponent` requires a `DotCMSPageAsset` object to be passed in to it. This object represents a dotCMS page and can be fetched using the `@dotcms/client` library.
99
104
 
100
- - [DotCMS Official Angular Example](https://github.com/dotCMS/core/tree/main/examples/angular)
105
+ - [DotCMS Official Angular Example](https://www.github.com/dotCMS/core/tree/main/examples/angular)
101
106
  - [`@dotcms/client` documentation](https://www.npmjs.com/package/@dotcms/client)
102
- - [Page API documentation](https://dotcms.com/docs/latest/page-api)
107
+ - [Page API documentation](https://www.dotcms.com/docs/latest/page-api)
103
108
 
104
109
  ## Components
105
110
 
@@ -167,17 +172,58 @@ This setup allows for dynamic rendering of different content types on your dotCM
167
172
 
168
173
  ## Troubleshooting
169
174
 
170
- If you encounter issues:
175
+ If you encounter issues while using `@dotcms/angular`, here are some common problems and their solutions:
176
+
177
+ 1. **Dependency Issues**:
178
+ - Ensure that all dependencies, such as `@dotcms/client`, `@angular/core`, and `rxjs`, are correctly installed and up-to-date. You can verify installed versions by running:
179
+ ```bash
180
+ npm list @dotcms/client @angular/core rxjs
181
+ ```
182
+ - If there are any missing or incompatible versions, reinstall dependencies by running:
183
+ ```bash
184
+ npm install
185
+ ```
186
+ or
187
+ ```bash
188
+ npm install --force
189
+ ```
190
+
191
+ 2. **Configuration Errors**:
192
+ - **DotCMS Configuration**: Double-check that your `DOTCMS_CLIENT_CONFIG` settings (URL, auth token, site ID) are correct and aligned with the environment variables. For example:
193
+ ```typescript
194
+ const DOTCMS_CLIENT_CONFIG: ClientConfig = {
195
+ dotcmsUrl: environment.dotcmsUrl, // Ensure this is a valid URL
196
+ authToken: environment.authToken, // Ensure auth token has the correct permissions
197
+ siteId: environment.siteId // Ensure site ID is valid and accessible
198
+ };
199
+ ```
200
+ - **Injection Issues**: Ensure that `DOTCMS_CLIENT_TOKEN` is provided globally. Errors like `NullInjectorError` usually mean the token hasn’t been properly added to the `ApplicationConfig`. Verify by checking `src/app/app.config.ts`.
201
+
202
+ 3. **Network and API Errors**:
203
+ - **dotCMS API Connectivity**: If API calls are failing, check your browser’s Network tab to ensure requests to `dotcmsUrl` are successful. For CORS-related issues, ensure that your dotCMS server allows requests from your application’s domain.
204
+ - **Auth Token Permissions**: If you’re seeing `401 Unauthorized` errors, make sure the auth token used in `DOTCMS_CLIENT_CONFIG` has appropriate permissions in dotCMS for accessing pages and content.
205
+
206
+ 4. **Page and Component Rendering**:
207
+ - **Dynamic Imports**: If you’re encountering issues with lazy-loaded components, make sure dynamic imports are correctly set up, as in:
208
+ ```typescript
209
+ const DYNAMIC_COMPONENTS: DotCMSPageComponent = {
210
+ Activity: import('../pages/content-types/activity/activity.component').then(
211
+ (c) => c.ActivityComponent
212
+ )
213
+ };
214
+ ```
215
+ - **Invalid Page Assets**: Ensure that `pageAsset` objects are correctly formatted. Missing fields in `pageAsset` can cause errors in `DotcmsLayoutComponent`. Validate the structure by logging `pageAsset` before passing it in.
216
+
217
+ 5. **Common Angular Errors**:
218
+ - **Change Detection**: Angular sometimes fails to detect changes with dynamic content. If `DotcmsLayoutComponent` isn’t updating as expected, you may need to call `ChangeDetectorRef.detectChanges()` manually.
219
+ - **TypeScript Type Errors**: Ensure all types (e.g., `DotCMSPageAsset`, `DotCMSPageComponent`) are imported correctly from `@dotcms/angular`. Type mismatches can often be resolved by verifying imports.
171
220
 
172
- 1. Ensure all dependencies are correctly installed and up to date.
173
- 2. Verify that your dotCMS configuration (URL, auth token, site ID) is correct.
174
- 3. Check the browser console for any error messages.
175
- 4. Refer to the [dotCMS documentation](https://dotcms.com/docs/) for additional guidance.
221
+ 6. **Consult Documentation**: Refer to the official [dotCMS documentation](https://dotcms.com/docs/) and the [@dotcms/angular GitHub repository](https://github.com/dotCMS/core). These sources often provide updates and additional usage examples.
176
222
 
177
223
  ## Contributing
178
224
 
179
- GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the [dotCMS Contributor's Agreement](https://gist.github.com/wezell/85ef45298c48494b90d92755b583acb3).
225
+ GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the [dotCMS Contributor's Agreement](https://www.gist.github.com/wezell/85ef45298c48494b90d92755b583acb3).
180
226
 
181
227
  ## Licensing
182
228
 
183
- dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://dotcms.com/cms-platform/features).
229
+ dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://www.dotcms.com/cms-platform/features).
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dotcms/angular",
3
- "version": "0.0.1-alpha.44",
3
+ "version": "0.0.1-alpha.46",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=17.0.0",
6
- "@angular/core": "=>17.0.0",
7
- "@angular/router": "=>17.0.0",
8
- "@dotcms/client": "0.0.1-alpha.44",
6
+ "@angular/core": ">=17.0.0",
7
+ "@angular/router": ">=17.0.0",
8
+ "@dotcms/client": "0.0.1-alpha.46",
9
9
  "@tinymce/tinymce-angular": "^8.0.0",
10
10
  "rxjs": ">=7.0.0"
11
11
  },