create-sitecore-jss 22.10.0-canary.1 → 22.10.0-canary.10
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.
- package/LICENSE.MD +1 -1
- package/dist/templates/angular/angular.json +133 -133
- package/dist/templates/angular/package.json +118 -119
- package/dist/templates/angular/scripts/generate-component-factory/template.ts +1 -3
- package/dist/templates/angular/server.bundle.ts +3 -2
- package/dist/templates/angular/src/app/ViewBag.ts +4 -0
- package/dist/templates/angular/src/app/app.component.ts +10 -9
- package/dist/templates/angular/src/app/app.module.ts +3 -1
- package/dist/templates/angular/src/app/app.server.module.ts +2 -1
- package/dist/templates/angular/src/app/components/app-components.shared.module.ts +16 -3
- package/dist/templates/angular/src/app/components/content-block/content-block.component.ts +2 -1
- package/dist/templates/angular/src/app/i18n/jss-translation-client-loader.service.ts +3 -2
- package/dist/templates/angular/src/app/i18n/jss-translation-server-loader.service.ts +8 -4
- package/dist/templates/angular/src/app/injection-tokens.ts +13 -0
- package/dist/templates/angular/src/app/jss-context.server-side.service.ts +8 -10
- package/dist/templates/angular/src/app/jss-context.service.ts +6 -4
- package/dist/templates/angular/src/app/jss-graphql.module.ts +58 -48
- package/dist/templates/angular/src/app/jss-graphql.service.ts +6 -6
- package/dist/templates/angular/src/app/jss-meta.service.ts +3 -2
- package/dist/templates/angular/src/app/routing/layout/layout.component.ts +10 -4
- package/dist/templates/angular/src/app/routing/navigation/navigation.component.ts +3 -0
- package/dist/templates/angular/src/app/routing/not-found/not-found.component.ts +1 -1
- package/dist/templates/angular/src/app/routing/routing.module.ts +3 -4
- package/dist/templates/angular/src/app/routing/scripts/scripts.module.ts +1 -1
- package/dist/templates/angular-sxp/src/app/components/app-components.shared.module.ts +1 -3
- package/dist/templates/angular-sxp/src/app/components/graph-ql-connected-demo/graph-ql-connected-demo.component.html +41 -39
- package/dist/templates/angular-sxp/src/app/components/graph-ql-connected-demo/graph-ql-connected-demo.component.ts +5 -3
- package/dist/templates/angular-sxp/src/app/components/graph-ql-integrated-demo/graph-ql-integrated-demo.component.html +6 -4
- package/dist/templates/angular-sxp/src/app/components/graph-ql-integrated-demo/graph-ql-integrated-demo.component.ts +4 -4
- package/dist/templates/angular-sxp/src/app/components/graph-ql-layout/graph-ql-layout.component.html +3 -4
- package/dist/templates/angular-sxp/src/app/components/graph-ql-layout/graph-ql-layout.component.ts +4 -4
- package/dist/templates/angular-sxp/src/app/components/shared/styleguide-specimen/styleguide-specimen.component.ts +3 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-angular-lazy-loading/styleguide-angular-lazy-loading.component.ts +5 -5
- package/dist/templates/angular-sxp/src/app/components/styleguide-angular-lazy-loading/styleguide-angular-lazy-loading.module.ts +2 -5
- package/dist/templates/angular-sxp/src/app/components/styleguide-component-params/styleguide-component-params.component.html +8 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-component-params/styleguide-component-params.component.ts +2 -2
- package/dist/templates/angular-sxp/src/app/components/styleguide-custom-route-type/styleguide-custom-route-type.component.ts +5 -5
- package/dist/templates/angular-sxp/src/app/components/styleguide-edit-frame/styleguide-edit-frame.component.html +7 -3
- package/dist/templates/angular-sxp/src/app/components/styleguide-edit-frame/styleguide-edit-frame.component.ts +13 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-checkbox/styleguide-field-usage-checkbox.component.ts +2 -2
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-content-list/styleguide-field-usage-content-list.component.html +20 -16
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-content-list/styleguide-field-usage-content-list.component.ts +20 -3
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-custom/styleguide-field-usage-custom.component.ts +2 -0
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-date/styleguide-field-usage-date.component.ts +4 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-file/styleguide-field-usage-file.component.ts +3 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-image/styleguide-field-usage-image.component.ts +3 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-item-link/styleguide-field-usage-item-link.component.html +4 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-item-link/styleguide-field-usage-item-link.component.ts +4 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-link/styleguide-field-usage-link.component.ts +3 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-number/styleguide-field-usage-number.component.ts +2 -0
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-rich-text/styleguide-field-usage-rich-text.component.ts +3 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-field-usage-text/styleguide-field-usage-text.component.ts +3 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout/styleguide-layout.component.html +12 -8
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout/styleguide-layout.component.ts +2 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout-reuse/styleguide-layout-reuse.component.ts +3 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout-tabs/styleguide-layout-tabs.component.html +18 -15
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout-tabs/styleguide-layout-tabs.component.ts +6 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout-tabs-tab/styleguide-layout-tabs-tab.component.html +2 -2
- package/dist/templates/angular-sxp/src/app/components/styleguide-layout-tabs-tab/styleguide-layout-tabs-tab.component.ts +4 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-multilingual/styleguide-multilingual.component.ts +7 -3
- package/dist/templates/angular-sxp/src/app/components/styleguide-route-fields/styleguide-route-fields.component.ts +5 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-section/styleguide-section.component.ts +2 -1
- package/dist/templates/angular-sxp/src/app/components/styleguide-sitecore-context/styleguide-sitecore-context.component.ts +7 -4
- package/dist/templates/angular-sxp/src/app/components/styleguide-tracking/styleguide-tracking.component.html +6 -2
- package/dist/templates/angular-sxp/src/app/components/styleguide-tracking/styleguide-tracking.component.ts +12 -12
- package/dist/templates/angular-sxp/src/app/jss-data-fetcher.service.ts +4 -2
- package/dist/templates/angular-sxp/src/app/routing/scripts/scripts.component.ts +10 -0
- package/dist/templates/angular-sxp/src/app/routing/scripts/scripts.module.ts +1 -1
- package/dist/templates/angular-sxp/src/app/routing/scripts/visitor-identification/visitor-identification.component.ts +6 -3
- package/dist/templates/angular-xmcloud/scripts/generate-component-factory/template.ts +1 -3
- package/dist/templates/angular-xmcloud/src/app/components/app-components.shared.module.ts +1 -2
- package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.html +6 -4
- package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.ts +4 -1
- package/dist/templates/angular-xmcloud/src/app/components/container/container.component.html +14 -5
- package/dist/templates/angular-xmcloud/src/app/components/container/container.component.ts +3 -0
- package/dist/templates/angular-xmcloud/src/app/components/image/image.component.html +21 -23
- package/dist/templates/angular-xmcloud/src/app/components/image/image.component.ts +5 -5
- package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.html +11 -10
- package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.ts +3 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.html +14 -17
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.ts +3 -3
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.html +3 -6
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.ts +8 -5
- package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.ts +4 -4
- package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.ts +2 -0
- package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.html +4 -6
- package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.ts +3 -0
- package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.html +3 -4
- package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.ts +3 -0
- package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.html +10 -9
- package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.ts +3 -0
- package/dist/templates/angular-xmcloud/src/app/components/title/title.component.html +4 -5
- package/dist/templates/angular-xmcloud/src/app/components/title/title.component.ts +5 -5
- package/dist/templates/angular-xmcloud/src/app/jss-link.service.ts +2 -2
- package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.html +38 -36
- package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.ts +10 -6
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/cdp-page-view.component.ts +2 -3
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/cloud-sdk-init.component.ts +2 -2
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.component.ts +13 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.module.ts +1 -2
- package/dist/templates/nextjs/src/lib/component-props/index.ts +40 -0
- package/dist/templates/nextjs/src/lib/page-props-factory/plugins/component-props.ts +4 -37
- package/dist/templates/nextjs-sxa/src/pages/404.tsx +30 -17
- package/dist/templates/nextjs-sxa/src/pages/500.tsx +30 -17
- package/package.json +2 -2
package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
1
|
+
import { Component, OnInit, OnDestroy, inject } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
4
|
import { Subscription } from 'rxjs';
|
|
3
5
|
import { SxaComponent } from '../sxa.component';
|
|
4
6
|
import { JssContextService } from '../../jss-context.service';
|
|
7
|
+
import { NavigationItemComponent } from './navigation-item.component';
|
|
5
8
|
|
|
6
9
|
@Component({
|
|
7
10
|
selector: 'app-navigation',
|
|
8
11
|
templateUrl: './navigation.component.html',
|
|
12
|
+
imports: [CommonModule, JssModule, NavigationItemComponent],
|
|
9
13
|
host: {
|
|
10
14
|
'class': 'component navigation',
|
|
11
15
|
'[id]': 'id',
|
|
@@ -17,16 +21,15 @@ export class NavigationComponent extends SxaComponent implements OnInit, OnDestr
|
|
|
17
21
|
private contextSubscription: Subscription;
|
|
18
22
|
isOpenMenu = false;
|
|
19
23
|
baseLevel = 1;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
super();
|
|
23
|
-
}
|
|
24
|
+
private jssContext = inject(JssContextService);
|
|
25
|
+
fieldKeys: string[];
|
|
24
26
|
|
|
25
27
|
ngOnInit() {
|
|
26
28
|
super.ngOnInit();
|
|
27
29
|
this.contextSubscription = this.jssContext.state.subscribe((newState) => {
|
|
28
30
|
this.isEditing = newState.sitecore && newState.sitecore.context.pageEditing;
|
|
29
31
|
});
|
|
32
|
+
this.fieldKeys = Object.keys(this.rendering.fields || {});
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
ngOnDestroy() {
|
package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
|
|
2
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
3
|
import { RichTextField } from '@sitecore-jss/sitecore-jss-angular';
|
|
3
4
|
import { JssContextService } from '../../jss-context.service';
|
|
4
5
|
import { SxaComponent } from './../sxa.component';
|
|
@@ -7,6 +8,7 @@ import { Subscription } from 'rxjs';
|
|
|
7
8
|
@Component({
|
|
8
9
|
selector: 'app-page-content',
|
|
9
10
|
templateUrl: './page-content.component.html',
|
|
11
|
+
imports: [JssModule],
|
|
10
12
|
host: {
|
|
11
13
|
'class': 'component content',
|
|
12
14
|
'[class]': 'styles',
|
|
@@ -17,10 +19,8 @@ export class PageContentComponent extends SxaComponent implements OnInit, OnDest
|
|
|
17
19
|
content?: RichTextField;
|
|
18
20
|
contextContent?: RichTextField;
|
|
19
21
|
private contextSubscription: Subscription;
|
|
22
|
+
private jssContext = inject(JssContextService);
|
|
20
23
|
|
|
21
|
-
constructor(private jssContext: JssContextService) {
|
|
22
|
-
super();
|
|
23
|
-
}
|
|
24
24
|
ngOnInit() {
|
|
25
25
|
super.ngOnInit();
|
|
26
26
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Component, OnInit } from '@angular/core';
|
|
2
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
3
|
import { SxaComponent } from '../sxa.component';
|
|
3
4
|
|
|
4
5
|
@Component({
|
|
5
6
|
selector: 'app-partial-design-dynamic-placeholder',
|
|
6
7
|
templateUrl: './partial-design-dynamic-placeholder.component.html',
|
|
8
|
+
imports: [JssModule]
|
|
7
9
|
})
|
|
8
10
|
export class PartialDesignDynamicPlaceholderComponent extends SxaComponent implements OnInit {
|
|
9
11
|
sig: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div class="component-content">
|
|
2
|
-
|
|
2
|
+
@if (rendering.fields) {
|
|
3
3
|
<div class="field-promoicon">
|
|
4
4
|
<img *scImage="rendering.fields.PromoIcon" />
|
|
5
5
|
</div>
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
<a *scGenericLink="rendering.fields.PromoLink"></a>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
16
|
-
|
|
16
|
+
} @else {
|
|
17
|
+
<span className="is-empty-hint">Promo</span>
|
|
18
|
+
}
|
|
17
19
|
</div>
|
|
18
|
-
|
|
19
|
-
<ng-template #empty>
|
|
20
|
-
<span className="is-empty-hint">Promo</span>
|
|
21
|
-
</ng-template>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Component } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
4
|
import { SxaComponent } from '../sxa.component';
|
|
3
5
|
|
|
4
6
|
@Component({
|
|
5
7
|
selector: 'app-promo',
|
|
6
8
|
templateUrl: './promo.component.html',
|
|
9
|
+
imports: [CommonModule, JssModule],
|
|
7
10
|
host: {
|
|
8
11
|
'class': 'component promo',
|
|
9
12
|
'[class]': "styles",
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Component, OnInit } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
4
|
import { Field } from '@sitecore-jss/sitecore-jss-angular';
|
|
3
5
|
import { SxaComponent } from '../sxa.component';
|
|
4
6
|
|
|
5
7
|
@Component({
|
|
6
8
|
selector: 'app-richtext',
|
|
7
9
|
templateUrl: './richtext.component.html',
|
|
10
|
+
imports: [CommonModule, JssModule],
|
|
8
11
|
host: {
|
|
9
12
|
'class': 'component rich-text',
|
|
10
13
|
'[class]': "styles",
|
package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.html
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
@for (ph of enabledPlaceholders; track ph) {
|
|
2
|
+
<div
|
|
3
|
+
class="container-fluid"
|
|
4
|
+
[ngClass]="getRowClass(+ph - 1)"
|
|
5
|
+
>
|
|
6
|
+
<div>
|
|
7
|
+
<div class="row">
|
|
8
|
+
<sc-placeholder [name]="getPlaceholderName(ph)" [rendering]="rendering"> </sc-placeholder>
|
|
9
|
+
</div>
|
|
9
10
|
</div>
|
|
10
11
|
</div>
|
|
11
|
-
|
|
12
|
+
}
|
package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Component } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
4
|
import { SxaComponent } from '../sxa.component';
|
|
3
5
|
|
|
4
6
|
@Component({
|
|
5
7
|
selector: 'app-row-splitter',
|
|
6
8
|
templateUrl: './row-splitter.component.html',
|
|
9
|
+
imports: [CommonModule, JssModule],
|
|
7
10
|
host: {
|
|
8
11
|
"class": "component row-splitter",
|
|
9
12
|
"[class]": "rowSplitterStyles",
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<div clas="component-content">
|
|
2
2
|
<div class="field-title">
|
|
3
|
-
|
|
3
|
+
@if (!pageEditing) {
|
|
4
4
|
<a *scGenericLink="link"></a>
|
|
5
|
-
|
|
5
|
+
} @else {
|
|
6
|
+
<span *scText="text"></span>
|
|
7
|
+
}
|
|
6
8
|
</div>
|
|
7
9
|
</div>
|
|
8
|
-
<ng-template #textOnly>
|
|
9
|
-
<span *scText="text"></span>
|
|
10
|
-
</ng-template>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Component, OnDestroy, OnInit } from '@angular/core';
|
|
1
|
+
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
2
4
|
import { LinkField, SxaTitleFields, TextField } from '@sitecore-jss/sitecore-jss-angular';
|
|
3
5
|
import { SxaComponent } from '../sxa.component';
|
|
4
6
|
import { Subscription } from 'rxjs';
|
|
@@ -7,6 +9,7 @@ import { JssContextService } from '../../jss-context.service';
|
|
|
7
9
|
@Component({
|
|
8
10
|
selector: 'app-title',
|
|
9
11
|
templateUrl: './title.component.html',
|
|
12
|
+
imports: [CommonModule, JssModule],
|
|
10
13
|
host: {
|
|
11
14
|
'class': 'component title',
|
|
12
15
|
'[class]': 'styles',
|
|
@@ -19,10 +22,7 @@ export class TitleComponent extends SxaComponent<SxaTitleFields> implements OnIn
|
|
|
19
22
|
pageEditing?: boolean;
|
|
20
23
|
|
|
21
24
|
private contextSubscription: Subscription;
|
|
22
|
-
|
|
23
|
-
constructor(private jssContext: JssContextService) {
|
|
24
|
-
super();
|
|
25
|
-
}
|
|
25
|
+
private jssContext = inject(JssContextService);
|
|
26
26
|
|
|
27
27
|
ngOnInit() {
|
|
28
28
|
super.ngOnInit();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
2
|
import { DOCUMENT } from '@angular/common';
|
|
3
3
|
import { HTMLLink } from '@sitecore-jss/sitecore-jss-angular';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import { HTMLLink } from '@sitecore-jss/sitecore-jss-angular';
|
|
|
6
6
|
providedIn: 'root',
|
|
7
7
|
})
|
|
8
8
|
export class JssLinkService {
|
|
9
|
-
|
|
9
|
+
private document = inject(DOCUMENT);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Adds link element in the document head.
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
<div class="{{ mainClassPageEditing }}">
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[errorContextData]="errorContextData"
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
@if (state === LayoutState.Layout) {
|
|
3
|
+
<ng-container>
|
|
4
|
+
<app-scripts></app-scripts>
|
|
5
|
+
<header>
|
|
6
|
+
<div id="header">
|
|
7
|
+
<sc-placeholder
|
|
8
|
+
name="headless-header"
|
|
9
|
+
[rendering]="route"
|
|
10
|
+
(loaded)="onPlaceholderLoaded($event)"
|
|
11
|
+
></sc-placeholder>
|
|
12
|
+
</div>
|
|
13
|
+
</header>
|
|
14
|
+
<main>
|
|
15
|
+
<div id="content">
|
|
16
|
+
<sc-placeholder
|
|
17
|
+
name="headless-main"
|
|
18
|
+
[rendering]="route"
|
|
19
|
+
(loaded)="onPlaceholderLoaded($event)"
|
|
20
|
+
></sc-placeholder>
|
|
21
|
+
</div>
|
|
22
|
+
</main>
|
|
23
|
+
<footer>
|
|
24
|
+
<div id="footer">
|
|
25
|
+
<sc-placeholder
|
|
26
|
+
name="headless-footer"
|
|
27
|
+
[rendering]="route"
|
|
28
|
+
(loaded)="onPlaceholderLoaded($event)"
|
|
29
|
+
></sc-placeholder>
|
|
30
|
+
</div>
|
|
31
|
+
</footer>
|
|
32
|
+
</ng-container>
|
|
33
|
+
}
|
|
34
|
+
@if (state === LayoutState.NotFound) {
|
|
35
|
+
<app-not-found [errorContextData]="errorContextData"></app-not-found>
|
|
36
|
+
}
|
|
37
|
+
@if (state === LayoutState.Error) {
|
|
38
|
+
<app-server-error></app-server-error>
|
|
39
|
+
}
|
|
38
40
|
</div>
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
/* eslint-disable no-shadow, no-console */
|
|
2
|
-
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { Component, OnInit, OnDestroy, inject } from '@angular/core';
|
|
3
3
|
import {
|
|
4
4
|
RouteData,
|
|
5
5
|
Field,
|
|
6
6
|
LayoutServiceContextData,
|
|
7
7
|
getContentStylesheetLink,
|
|
8
|
+
JssModule,
|
|
8
9
|
} from '@sitecore-jss/sitecore-jss-angular';
|
|
9
10
|
import { ActivatedRoute } from '@angular/router';
|
|
10
11
|
import { Subscription } from 'rxjs';
|
|
11
12
|
import { JssState } from '../../JssState';
|
|
12
13
|
import { JssMetaService } from '../../jss-meta.service';
|
|
13
14
|
import { JssLinkService } from '../../jss-link.service';
|
|
15
|
+
import { NotFoundComponent } from '../not-found/not-found.component';
|
|
16
|
+
import { ServerErrorComponent } from '../server-error/server-error.component';
|
|
17
|
+
import { ScriptsComponent } from '../scripts/scripts.component';
|
|
14
18
|
import { environment as env } from '../../../environments/environment';
|
|
19
|
+
import { CommonModule } from '@angular/common';
|
|
15
20
|
|
|
16
21
|
enum LayoutState {
|
|
17
22
|
Layout,
|
|
@@ -27,6 +32,7 @@ interface RouteFields {
|
|
|
27
32
|
@Component({
|
|
28
33
|
selector: 'app-layout',
|
|
29
34
|
templateUrl: './layout.component.html',
|
|
35
|
+
imports: [CommonModule, JssModule, NotFoundComponent, ServerErrorComponent, ScriptsComponent],
|
|
30
36
|
})
|
|
31
37
|
export class LayoutComponent implements OnInit, OnDestroy {
|
|
32
38
|
route: RouteData<RouteFields>;
|
|
@@ -36,11 +42,9 @@ export class LayoutComponent implements OnInit, OnDestroy {
|
|
|
36
42
|
errorContextData: LayoutServiceContextData;
|
|
37
43
|
mainClassPageEditing: string;
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
private linkService: JssLinkService
|
|
43
|
-
) {}
|
|
45
|
+
private activatedRoute = inject(ActivatedRoute);
|
|
46
|
+
private readonly meta = inject(JssMetaService);
|
|
47
|
+
private linkService = inject(JssLinkService);
|
|
44
48
|
|
|
45
49
|
ngOnInit() {
|
|
46
50
|
// route data is populated by the JssRouteResolver
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, OnInit, OnDestroy } from '@angular/core';
|
|
1
|
+
import { Component, OnInit, OnDestroy, inject } from '@angular/core';
|
|
2
2
|
import { Subscription } from 'rxjs';
|
|
3
3
|
import { isServer, CdpHelper, LayoutServicePageState } from '@sitecore-jss/sitecore-jss-angular';
|
|
4
4
|
import { pageView, PageViewData } from '@sitecore-cloudsdk/events/browser';
|
|
@@ -18,8 +18,7 @@ import { environment } from '../../../environments/environment';
|
|
|
18
18
|
})
|
|
19
19
|
export class CdpPageViewComponent implements OnInit, OnDestroy {
|
|
20
20
|
private contextSubscription: Subscription;
|
|
21
|
-
|
|
22
|
-
constructor(private jssContext: JssContextService) {}
|
|
21
|
+
private jssContext = inject(JssContextService);
|
|
23
22
|
|
|
24
23
|
ngOnInit(): void {
|
|
25
24
|
if (!isServer()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, OnInit } from '@angular/core';
|
|
1
|
+
import { Component, OnInit, inject } from '@angular/core';
|
|
2
2
|
import { take } from 'rxjs/operators';
|
|
3
3
|
import { CloudSDK } from '@sitecore-cloudsdk/core/browser';
|
|
4
4
|
import '@sitecore-cloudsdk/events/browser';
|
|
@@ -15,7 +15,7 @@ import { JssState } from '../../JssState';
|
|
|
15
15
|
template: '',
|
|
16
16
|
})
|
|
17
17
|
export class CloudSdkInitComponent implements OnInit {
|
|
18
|
-
|
|
18
|
+
private jssContext = inject(JssContextService);
|
|
19
19
|
|
|
20
20
|
ngOnInit(): void {
|
|
21
21
|
if (!isServer() && environment.production) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
|
|
4
|
+
import { CloudSdkInitComponent } from './cloud-sdk-init.component';
|
|
5
|
+
import { CdpPageViewComponent } from './cdp-page-view.component';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'app-scripts',
|
|
9
|
+
templateUrl: './scripts.component.html',
|
|
10
|
+
imports: [CommonModule, JssModule, CloudSdkInitComponent, CdpPageViewComponent]
|
|
11
|
+
})
|
|
12
|
+
export class ScriptsComponent {}
|
|
13
|
+
|
|
@@ -5,8 +5,7 @@ import { CloudSdkInitComponent } from './cloud-sdk-init.component';
|
|
|
5
5
|
import { CdpPageViewComponent } from './cdp-page-view.component';
|
|
6
6
|
|
|
7
7
|
@NgModule({
|
|
8
|
+
imports: [JssModule, ScriptsComponent, CloudSdkInitComponent, CdpPageViewComponent],
|
|
8
9
|
exports: [ScriptsComponent],
|
|
9
|
-
imports: [JssModule],
|
|
10
|
-
declarations: [ScriptsComponent, CloudSdkInitComponent, CdpPageViewComponent],
|
|
11
10
|
})
|
|
12
11
|
export class ScriptsModule {}
|
|
@@ -2,7 +2,14 @@ import {
|
|
|
2
2
|
ComponentParams,
|
|
3
3
|
ComponentRendering,
|
|
4
4
|
SitecoreContextValue,
|
|
5
|
+
LayoutServiceData,
|
|
6
|
+
ComponentPropsService,
|
|
7
|
+
ComponentPropsCollection,
|
|
8
|
+
ComponentPropsError,
|
|
5
9
|
} from '@sitecore-jss/sitecore-jss-nextjs';
|
|
10
|
+
import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
|
|
11
|
+
import { isServerSidePropsContext } from 'lib/page-props-factory';
|
|
12
|
+
import { moduleFactory } from 'temp/componentBuilder';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Shared component props
|
|
@@ -21,3 +28,36 @@ export type ComponentProps = {
|
|
|
21
28
|
export type ComponentWithContextProps = ComponentProps & {
|
|
22
29
|
sitecoreContext: SitecoreContextValue;
|
|
23
30
|
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fetch component props for a given layout data and context
|
|
34
|
+
* @param {LayoutServiceData} layoutData - The layout data to fetch component props for
|
|
35
|
+
* @param {GetServerSidePropsContext | GetStaticPropsContext} context - The context to fetch component props for
|
|
36
|
+
* @returns {ComponentPropsCollection} The component props
|
|
37
|
+
* @throws {Error} If there are errors during component props fetching
|
|
38
|
+
*/
|
|
39
|
+
export async function fetchComponentProps(
|
|
40
|
+
layoutData: LayoutServiceData,
|
|
41
|
+
context: GetServerSidePropsContext | GetStaticPropsContext
|
|
42
|
+
): Promise<ComponentPropsCollection> {
|
|
43
|
+
const service = new ComponentPropsService();
|
|
44
|
+
|
|
45
|
+
const componentProps = isServerSidePropsContext(context)
|
|
46
|
+
? await service.fetchServerSideComponentProps({ layoutData, context, moduleFactory })
|
|
47
|
+
: await service.fetchStaticComponentProps({ layoutData, context, moduleFactory });
|
|
48
|
+
|
|
49
|
+
const errors = Object.keys(componentProps)
|
|
50
|
+
.map(id => {
|
|
51
|
+
const c = componentProps[id] as ComponentPropsError;
|
|
52
|
+
return c?.error
|
|
53
|
+
? `\nUnable to get component props for ${c.componentName} (${id}): ${c.error}`
|
|
54
|
+
: '';
|
|
55
|
+
})
|
|
56
|
+
.join('');
|
|
57
|
+
|
|
58
|
+
if (errors.length) {
|
|
59
|
+
throw new Error(errors);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return componentProps;
|
|
63
|
+
}
|
|
@@ -1,50 +1,17 @@
|
|
|
1
|
-
import { ComponentPropsService, ComponentPropsError } from '@sitecore-jss/sitecore-jss-nextjs';
|
|
2
|
-
import { SitecorePageProps } from 'lib/page-props';
|
|
3
1
|
import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { SitecorePageProps } from 'lib/page-props';
|
|
3
|
+
import { fetchComponentProps } from 'lib/component-props';
|
|
4
|
+
import { Plugin } from '..';
|
|
6
5
|
|
|
7
6
|
class ComponentPropsPlugin implements Plugin {
|
|
8
|
-
private componentPropsService: ComponentPropsService;
|
|
9
|
-
|
|
10
7
|
// Make sure to run this plugin last to ensure that the updated layout data is used
|
|
11
8
|
order = 10;
|
|
12
9
|
|
|
13
|
-
constructor() {
|
|
14
|
-
this.componentPropsService = new ComponentPropsService();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
10
|
async exec(props: SitecorePageProps, context: GetServerSidePropsContext | GetStaticPropsContext) {
|
|
18
11
|
if (!props.layoutData.sitecore.route) return props;
|
|
19
12
|
|
|
20
13
|
// Retrieve component props using side-effects defined on components level
|
|
21
|
-
|
|
22
|
-
props.componentProps = await this.componentPropsService.fetchServerSideComponentProps({
|
|
23
|
-
layoutData: props.layoutData,
|
|
24
|
-
context,
|
|
25
|
-
moduleFactory,
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
props.componentProps = await this.componentPropsService.fetchStaticComponentProps({
|
|
29
|
-
layoutData: props.layoutData,
|
|
30
|
-
context,
|
|
31
|
-
moduleFactory,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const errors = Object.keys(props.componentProps)
|
|
36
|
-
.map(id => {
|
|
37
|
-
const component = props.componentProps[id] as ComponentPropsError;
|
|
38
|
-
|
|
39
|
-
return component.error
|
|
40
|
-
? `\nUnable to get component props for ${component.componentName} (${id}): ${component.error}`
|
|
41
|
-
: '';
|
|
42
|
-
})
|
|
43
|
-
.join('');
|
|
44
|
-
|
|
45
|
-
if (errors.length) {
|
|
46
|
-
throw new Error(errors);
|
|
47
|
-
}
|
|
14
|
+
props.componentProps = await fetchComponentProps(props.layoutData, context);
|
|
48
15
|
|
|
49
16
|
return props;
|
|
50
17
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { GetStaticProps } from 'next';
|
|
3
3
|
import {
|
|
4
4
|
GraphQLErrorPagesService,
|
|
5
5
|
SitecoreContext,
|
|
6
|
+
ComponentPropsContext,
|
|
6
7
|
ErrorPages,
|
|
7
8
|
} from '@sitecore-jss/sitecore-jss-nextjs';
|
|
8
9
|
import { SitecorePageProps } from 'lib/page-props';
|
|
9
10
|
import NotFound from 'src/NotFound';
|
|
10
11
|
import { componentBuilder } from 'temp/componentBuilder';
|
|
11
12
|
import Layout from 'src/Layout';
|
|
12
|
-
import { GetStaticProps } from 'next';
|
|
13
13
|
import { siteResolver } from 'lib/site-resolver';
|
|
14
|
+
import { fetchComponentProps } from 'lib/component-props';
|
|
14
15
|
import clientFactory from 'lib/graphql-client-factory';
|
|
16
|
+
import config from 'temp/config';
|
|
15
17
|
|
|
16
18
|
const Custom404 = (props: SitecorePageProps): JSX.Element => {
|
|
17
19
|
if (!(props && props.layoutData)) {
|
|
@@ -19,20 +21,22 @@ const Custom404 = (props: SitecorePageProps): JSX.Element => {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
return (
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
<ComponentPropsContext value={props.componentProps}>
|
|
25
|
+
<SitecoreContext
|
|
26
|
+
componentFactory={componentBuilder.getComponentFactory()}
|
|
27
|
+
layoutData={props.layoutData}
|
|
28
|
+
<% if (templates.includes('nextjs-xmcloud')) { %>
|
|
29
|
+
api={{
|
|
30
|
+
edge: {
|
|
31
|
+
contextId: config.sitecoreEdgeContextId,
|
|
32
|
+
edgeUrl: config.sitecoreEdgeUrl,
|
|
33
|
+
},
|
|
34
|
+
}}
|
|
35
|
+
<% } %>
|
|
36
|
+
>
|
|
37
|
+
<Layout layoutData={props.layoutData} headLinks={props.headLinks} />
|
|
38
|
+
</SitecoreContext>
|
|
39
|
+
</ComponentPropsContext>
|
|
36
40
|
);
|
|
37
41
|
};
|
|
38
42
|
|
|
@@ -58,10 +62,19 @@ export const getStaticProps: GetStaticProps = async (context) => {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
const layoutData = resultErrorPages?.notFoundPage?.rendered || null;
|
|
66
|
+
|
|
67
|
+
let componentProps = {};
|
|
68
|
+
|
|
69
|
+
if (layoutData?.sitecore?.route) {
|
|
70
|
+
componentProps = await fetchComponentProps(layoutData, context);
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
return {
|
|
62
74
|
props: {
|
|
63
75
|
headLinks: [],
|
|
64
|
-
layoutData
|
|
76
|
+
layoutData,
|
|
77
|
+
componentProps,
|
|
65
78
|
},
|
|
66
79
|
};
|
|
67
80
|
};
|