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

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,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.36",
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": "6c05bf93afe6709e8e730a1912b5eb9be9c65881"
67
67
  }