Skip to content

Commit c32ece3

Browse files
committed
publish(1.0.3): publish to npm
1 parent 4c09a70 commit c32ece3

File tree

3 files changed

+51
-16
lines changed

3 files changed

+51
-16
lines changed

libraries/ng-universal/README.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Angular Universal Helpers - Trilon
1+
# Angular Universal Schematics & Helpers - Trilon
22

33
[![npm](https://img.shields.io/npm/v/@trilon/ng-universal.svg?label=npm%20version&color=5b1096&style=for-the-badge)](https://www.npmjs.com/@trilon/ng-universal)
44
[![NPM Downloads](https://img.shields.io/npm/dt/@trilon/ng-universal.svg?color=b31ae7&style=for-the-badge)](https://www.npmjs.com/@trilon/ng-universal)
@@ -17,7 +17,7 @@
1717

1818
---
1919

20-
## Installation
20+
## Installation
2121

2222
Install & save the library to your package.json:
2323

@@ -33,24 +33,58 @@ Now add ApplicationInsightsModule to your Angular Root `AppModule`:
3333

3434
```typescript
3535
// Import the Application Insights module and the service provider
36-
import { --TODO-- } from '@trilon/ng-universal';
36+
import { NgUniversalModule } from '@trilon/ng-universal';
3737

3838
@NgModule({
3939
imports: [
40-
// ... your imports
41-
40+
// ...
4241
// Add the Module to your imports
43-
44-
],
45-
// ... providers / etc
46-
providers: [ ],
42+
NgUniversalModule
43+
]
4744
})
4845
export class AppModule { }
4946
```
5047

51-
## Usage
48+
# Angular Universal Helpers
49+
50+
Now that the Library is setup, you have a few great helpers to make Angular Universal a bit simpler and easier to work with!
51+
52+
## PlatformService
53+
54+
Typically in Angular Universal Applications you have sections of code that can only run in certain platforms (browser or server), with PlatformService you can simply add it in the constructor of any Component/Service within your application, and run code specific to that platform - without causing Errors in the _other_ platform.
55+
56+
```ts
57+
import { PlatformService } from '@trilon/ng-universal';
58+
59+
@Component({ /* ... */ })
60+
export SomeComponent {
61+
constructor(private platformService: PlatformService) {
62+
if (platformService.isBrowser) {
63+
// Run browser-specific code that would cause errors in the Server/Node platform!
64+
// $('body').addClass('');
65+
}
66+
67+
if (platformService.isServer) {
68+
// Run Server/Node-specific code
69+
}
70+
}
71+
}
72+
73+
```
74+
75+
## IsBrowser | IsService Directives
76+
77+
Equally important with Angular Universal is displaying only Components/UI that are _neccessary_ for the given platform. To improve performance, or to avoid Components all-together we can use `*isBrowser` or `*isServer` Directives to display/hide specific things given a platform.
78+
79+
Take as an example a Twitter Feed section that's connected to 3rd party Components/Libraries and API-calls. We don't need Universal to display these as there is no SEO benefit, and most likely they will slow down our Render time. In this case it's most beneficial to simply avoid it entirely during server-side rendering, and have _only_ the **Browser** display and render this Component!
80+
81+
```html
82+
<ng-container *isBrowser>
83+
<app-twitter-feed></app-twitter-feed>
84+
</ng-container>
85+
```
5286

53-
To do ....
87+
More Documentation Coming soon...
5488

5589

5690
# License

libraries/ng-universal/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "@trilon/ng-universal",
33
"description": "Angular Universal Schematics and Helpers - Brought to you by Trilon.io",
4-
"version": "1.0.0",
4+
"version": "1.0.3",
55
"author": {
66
"name": "Trion",
77
"email": "hello@trilon.io",
88
"url": "https://trilon.io"
99
},
10+
"homepage": "https://trilon.io",
1011
"contributors": [
1112
{
1213
"name": "Mark Pieszak",
@@ -28,9 +29,9 @@
2829
},
2930
"license": "MIT",
3031
"peerDependencies": {
31-
"@angular/common": "^7.2.0",
32-
"@angular/core": "^7.2.0",
33-
"@angular/platform-browser": "^7.2.0"
32+
"@angular/common": "^7.0.0",
33+
"@angular/core": "^7.0.0",
34+
"@angular/platform-browser": "^7.0.0"
3435
},
3536
"keywords": [
3637
"angular",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "ng build",
88
"build:ng-universal": "rm -rf ./dist/ng-universal && ng build ng-universal && npm run pack:ng-universal",
99
"pack:ng-universal": "cd dist/ng-universal && npm pack",
10-
"publish:ng-universal": "npm publish ./dist/ng-universal/trilon-ng-universal-1.0.0.tgz --access=public",
10+
"publish:ng-universal": "npm publish ./dist/ng-universal/trilon-ng-universal-1.0.3.tgz --access=public",
1111
"test": "ng test",
1212
"lint": "ng lint",
1313
"e2e": "ng e2e",

0 commit comments

Comments
 (0)