create-sitecore-jss 22.2.0-canary.35 → 22.2.0-canary.37

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.
@@ -0,0 +1,7 @@
1
+ <div class="component content {{styles}}" [attr.id]="id">
2
+ <div class="component-content">
3
+ <div class="field-content">
4
+ <div *scRichText="content || contextContent"></div>
5
+ </div>
6
+ </div>
7
+ </div>
@@ -0,0 +1,34 @@
1
+ import { Component, OnDestroy, OnInit } from '@angular/core';
2
+ import { RichTextField } from '@sitecore-jss/sitecore-jss-angular';
3
+ import { JssContextService } from '../../jss-context.service';
4
+ import { SxaComponent } from './../sxa.component';
5
+ import { Subscription } from 'rxjs';
6
+
7
+ @Component({
8
+ selector: 'app-page-content',
9
+ templateUrl: './page-content.component.html',
10
+ })
11
+ export class PageContentComponent extends SxaComponent implements OnInit, OnDestroy {
12
+ content?: RichTextField;
13
+ contextContent?: RichTextField;
14
+ private contextSubscription: Subscription;
15
+
16
+ constructor(private jssContext: JssContextService) {
17
+ super();
18
+ }
19
+ ngOnInit() {
20
+ super.ngOnInit();
21
+
22
+ this.content = this.rendering.fields?.Content as RichTextField;
23
+ this.contextSubscription = this.jssContext.state.subscribe((newState) => {
24
+ this.contextContent =
25
+ newState.sitecore && (newState.sitecore.route.fields.Content as RichTextField);
26
+ });
27
+ }
28
+
29
+ ngOnDestroy() {
30
+ if (this.contextSubscription) {
31
+ this.contextSubscription.unsubscribe();
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,12 @@
1
+ <div class="component title {{ styles }}" [attr.id]="id">
2
+ <div clas="component-content">
3
+ <div class="field-title">
4
+ <ng-container *ngIf="!pageEditing; else textOnly">
5
+ <a *scLink="link"></a>
6
+ </ng-container>
7
+ </div>
8
+ </div>
9
+ <ng-template #textOnly>
10
+ <span *scText="text"></span>
11
+ </ng-template>
12
+ </div>
@@ -0,0 +1,51 @@
1
+ import { Component, OnDestroy, OnInit } from '@angular/core';
2
+ import { LinkField, SxaTitleFields, TextField } from '@sitecore-jss/sitecore-jss-angular';
3
+ import { SxaComponent } from '../sxa.component';
4
+ import { Subscription } from 'rxjs';
5
+ import { JssContextService } from '../../jss-context.service';
6
+
7
+ @Component({
8
+ selector: 'app-title',
9
+ templateUrl: './title.component.html',
10
+ })
11
+ export class TitleComponent extends SxaComponent<SxaTitleFields> implements OnInit, OnDestroy {
12
+ text: TextField;
13
+ link: LinkField;
14
+ pageEditing?: boolean;
15
+
16
+ private contextSubscription: Subscription;
17
+
18
+ constructor(private jssContext: JssContextService) {
19
+ super();
20
+ }
21
+
22
+ ngOnInit() {
23
+ super.ngOnInit();
24
+ const datasource =
25
+ this.rendering.fields?.data?.datasource || this.rendering.fields?.data?.contextItem;
26
+ this.text = datasource.field?.jsonValue;
27
+ this.link = {
28
+ value: {
29
+ href: datasource?.url?.path,
30
+ title: datasource?.field?.jsonValue?.value,
31
+ text: datasource?.field?.jsonValue?.value,
32
+ },
33
+ };
34
+ this.contextSubscription = this.jssContext.state.subscribe(({ sitecore }) => {
35
+ this.pageEditing = sitecore.context.pageEditing;
36
+ if (sitecore.context.pageState !== 'normal') {
37
+ this.link.value.querystring = `sc_site=${datasource?.url?.siteName}`;
38
+ if (!this.text?.value) {
39
+ this.text.value = 'Title field';
40
+ this.link.value.href = '#';
41
+ }
42
+ }
43
+ });
44
+ }
45
+
46
+ ngOnDestroy() {
47
+ if (this.contextSubscription) {
48
+ this.contextSubscription.unsubscribe();
49
+ }
50
+ }
51
+ }
@@ -1,4 +1,3 @@
1
- <app-navigation></app-navigation>
2
1
  <div class="{{ mainClassPageEditing }}">
3
2
  <ng-container *ngIf="state === LayoutState.Layout">
4
3
  <app-scripts></app-scripts>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "22.2.0-canary.35",
3
+ "version": "22.2.0-canary.37",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -63,5 +63,5 @@
63
63
  "ts-node": "^10.9.1",
64
64
  "typescript": "~4.9.5"
65
65
  },
66
- "gitHead": "67c28920d9bb04df85415c3b662592c7cd1ad6e4"
66
+ "gitHead": "2f18bc17c4728742b8ba81f1df2c237d4102d14c"
67
67
  }