From e5c030c6652d58a9253a8450f58fbafb915a1cad Mon Sep 17 00:00:00 2001 From: Aleksey Belan Date: Fri, 30 Aug 2024 12:40:24 +0300 Subject: [PATCH] chore: format --- .../content/src/models/content.model.ts | 3 + .../cms-page-description-meta.resolver.ts | 6 +- .../resolvers/cms-page-title-meta.resolver.ts | 8 ++- libs/domain/content/src/resolvers/index.ts | 1 - .../content/src/services/cms/cms-providers.ts | 7 +- libs/domain/content/src/services/cms/index.ts | 1 - .../default-page-meta-resolver.service.ts | 11 ++-- .../data-text/data-text.component.ts | 1 + .../storefront/experience/pages/cms-pages.ts | 60 +++++++++-------- .../storefront/experience/pages/home-page.ts | 64 +++++++++++++------ .../storefront/experience/pages/index.ts | 1 - 11 files changed, 99 insertions(+), 64 deletions(-) diff --git a/libs/domain/content/src/models/content.model.ts b/libs/domain/content/src/models/content.model.ts index 2a11c68e3..973b6d632 100644 --- a/libs/domain/content/src/models/content.model.ts +++ b/libs/domain/content/src/models/content.model.ts @@ -1,5 +1,8 @@ declare global { interface ContentFields { + /** + * Page or component config. // ExperienceComponent + */ component: undefined; } } diff --git a/libs/domain/content/src/resolvers/cms-page-description-meta.resolver.ts b/libs/domain/content/src/resolvers/cms-page-description-meta.resolver.ts index 6ea262adf..cb5179568 100644 --- a/libs/domain/content/src/resolvers/cms-page-description-meta.resolver.ts +++ b/libs/domain/content/src/resolvers/cms-page-description-meta.resolver.ts @@ -22,7 +22,11 @@ export class CmsPageDescriptionMetaResolver implements PageMetaResolver { combineLatest([ this.context.get(null, ContentContext.Content), this.router.currentRoute(), - ]).pipe(map(([qualifier, route]) => route.includes(`/${qualifier?.type}/${qualifier?.id}`))), + ]).pipe( + map(([qualifier, route]) => + route.includes(`/${qualifier?.type}/${qualifier?.id}`) + ) + ), ]); } diff --git a/libs/domain/content/src/resolvers/cms-page-title-meta.resolver.ts b/libs/domain/content/src/resolvers/cms-page-title-meta.resolver.ts index 96569703e..1426d71af 100644 --- a/libs/domain/content/src/resolvers/cms-page-title-meta.resolver.ts +++ b/libs/domain/content/src/resolvers/cms-page-title-meta.resolver.ts @@ -5,7 +5,7 @@ import { } from '@oryx-frontend/core'; import { inject } from '@oryx-frontend/di'; import { RouterService } from '@oryx-frontend/router'; -import { combineLatest, map, Observable, of, switchMap } from 'rxjs'; +import { Observable, combineLatest, map, of, switchMap } from 'rxjs'; import { CmsContent, ContentQualifier } from '../models'; import { ContentContext, ContentService } from '../services'; @@ -22,7 +22,11 @@ export class CmsPageTitleMetaResolver implements PageMetaResolver { combineLatest([ this.context.get(null, ContentContext.Content), this.router.currentRoute(), - ]).pipe(map(([qualifier, route]) => route.includes(`/${qualifier?.type}/${qualifier?.id}`))), + ]).pipe( + map(([qualifier, route]) => + route.includes(`/${qualifier?.type}/${qualifier?.id}`) + ) + ), ]); } diff --git a/libs/domain/content/src/resolvers/index.ts b/libs/domain/content/src/resolvers/index.ts index 5a6630837..6c2a01c34 100644 --- a/libs/domain/content/src/resolvers/index.ts +++ b/libs/domain/content/src/resolvers/index.ts @@ -1,3 +1,2 @@ export * from './cms-page-description-meta.resolver'; export * from './cms-page-title-meta.resolver'; - diff --git a/libs/domain/content/src/services/cms/cms-providers.ts b/libs/domain/content/src/services/cms/cms-providers.ts index b5a5e9d56..658c36868 100644 --- a/libs/domain/content/src/services/cms/cms-providers.ts +++ b/libs/domain/content/src/services/cms/cms-providers.ts @@ -1,7 +1,10 @@ import { PageMetaResolver, provideEntity } from '@oryx-frontend/core'; import { Provider } from '@oryx-frontend/di'; -import { cmsTypes, Content, ContentQualifier } from '../../models'; -import { CmsPageDescriptionMetaResolver, CmsPageTitleMetaResolver } from '../../resolvers'; +import { Content, ContentQualifier, cmsTypes } from '../../models'; +import { + CmsPageDescriptionMetaResolver, + CmsPageTitleMetaResolver, +} from '../../resolvers'; import { ContentConfig } from '../adapter'; import { ContentService } from '../content.service'; import { CmsQualifierContextFallback } from './cms-context'; diff --git a/libs/domain/content/src/services/cms/index.ts b/libs/domain/content/src/services/cms/index.ts index 6664391f7..afde5c7f5 100644 --- a/libs/domain/content/src/services/cms/index.ts +++ b/libs/domain/content/src/services/cms/index.ts @@ -3,4 +3,3 @@ export * from './cms-providers'; export * from './contentful'; export * from './storyblok'; export * from './strapi'; - diff --git a/libs/platform/core/src/services/page-meta/page-meta-resolver/default-page-meta-resolver.service.ts b/libs/platform/core/src/services/page-meta/page-meta-resolver/default-page-meta-resolver.service.ts index 6af0db5cc..d697300de 100644 --- a/libs/platform/core/src/services/page-meta/page-meta-resolver/default-page-meta-resolver.service.ts +++ b/libs/platform/core/src/services/page-meta/page-meta-resolver/default-page-meta-resolver.service.ts @@ -35,12 +35,15 @@ export class DefaultPageMetaResolverService implements PageMetaResolverService { ]) ) ).pipe( - map((data) => data - .filter(([score, data]) => score !== ResolverScore.NotUsed && Object.keys(data).length) + map((data) => + data + .filter( + ([score, data]) => + score !== ResolverScore.NotUsed && Object.keys(data).length + ) .sort(([aScore], [bScore]) => aScore - bScore) .reduce((acc, [_, elements]) => ({ ...acc, ...elements }), {}) - ), - + ) ) ).pipe(shareReplay({ bufferSize: 1, refCount: true })); protected newData$ = this.data$.pipe( diff --git a/libs/platform/experience/data-text/data-text.component.ts b/libs/platform/experience/data-text/data-text.component.ts index fc0741bf2..804d5402a 100644 --- a/libs/platform/experience/data-text/data-text.component.ts +++ b/libs/platform/experience/data-text/data-text.component.ts @@ -20,6 +20,7 @@ export class DataTextComponent extends TextMixin( protected $data = computed(() => { const { entity: type, field } = this.$options(); + console.log(type, field); return this.entityService .getField({ element: this, type, field }) .pipe(catchError(() => of())); diff --git a/libs/template/presets/storefront/experience/pages/cms-pages.ts b/libs/template/presets/storefront/experience/pages/cms-pages.ts index eb9fbb72a..100f01c5e 100644 --- a/libs/template/presets/storefront/experience/pages/cms-pages.ts +++ b/libs/template/presets/storefront/experience/pages/cms-pages.ts @@ -1,36 +1,34 @@ import { cmsTypes } from '@oryx-frontend/content'; import { ExperienceComponent } from '@oryx-frontend/experience'; -export const cmsPages: ExperienceComponent[] = cmsTypes.map((type) => - ({ - type: 'Page', - id: type, - meta: { - title: type, - route: `/${type}/:id`, - routeType: type, - }, - components: [ - { ref: 'header' }, - { - type: 'oryx-composition', - options: { - rules: [{ layout: { type: 'split' }, padding: '30px 0' }], +export const cmsPages: ExperienceComponent[] = cmsTypes.map((type) => ({ + type: 'Page', + id: type, + meta: { + title: type, + route: `/${type}/:id`, + routeType: type, + }, + components: [ + { ref: 'header' }, + { + type: 'oryx-composition', + options: { + rules: [{ layout: { type: 'split' }, padding: '30px 0' }], + }, + components: [ + { + type: 'oryx-site-breadcrumb', + options: { rules: [{ colSpan: 2 }] }, }, - components: [ - { - type: 'oryx-site-breadcrumb', - options: { rules: [{ colSpan: 2 }] }, - }, - { - type: 'oryx-data-text', - options: { - field: 'content', - }, + { + type: 'oryx-data-text', + options: { + field: 'content', }, - ], - }, - { ref: 'footer' }, - ], - }), -); + }, + ], + }, + { ref: 'footer' }, + ], +})); diff --git a/libs/template/presets/storefront/experience/pages/home-page.ts b/libs/template/presets/storefront/experience/pages/home-page.ts index a28a756d5..79ad3442a 100644 --- a/libs/template/presets/storefront/experience/pages/home-page.ts +++ b/libs/template/presets/storefront/experience/pages/home-page.ts @@ -28,6 +28,12 @@ export const homePage: ExperienceComponent = { type: 'oryx-composition', id: 'home-hero', options: { + context: { + content: { + entities: ['article'], + id: 'home-hero', + }, + }, rules: [ { height: '550px', @@ -45,17 +51,25 @@ export const homePage: ExperienceComponent = { }, components: [ { - type: 'oryx-content-image', - name: 'hero', - content: { - data: { - link: `/category/12`, - alt: 'hero image', - image: - 'https://images.unsplash.com/photo-1670272505340-d906d8d77d03?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2370&q=80', - }, - }, + ...(featureVersion >= '1.5' + ? { + type: 'oryx-data-image', + } + : { + type: 'oryx-content-image', + name: 'hero', + content: { + data: { + link: `/category/12`, + alt: 'hero image', + image: + 'https://images.unsplash.com/photo-1670272505340-d906d8d77d03?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2370&q=80', + }, + }, + }), options: { + field: 'picture', + entity: 'article', ...(featureVersion >= '1.4' ? {} : { position: 'center 20%' }), rules: [ { @@ -70,18 +84,26 @@ export const homePage: ExperienceComponent = { }, }, { - type: 'oryx-content-text', - content: { - data: { - text: ` - CANON EOS R7 System camera -

Discover everything

-
EOS R7 wows with its ability to track fast-moving subjects with its Deep-learning Dual Pixel CMOS AF II focus system.
- Shop now - `, - }, - }, + ...(featureVersion >= '1.5' + ? { + type: 'oryx-data-text', + } + : { + type: 'oryx-content-text', + content: { + data: { + text: ` + CANON EOS R7 System camera +

Discover everything

+
EOS R7 wows with its ability to track fast-moving subjects with its Deep-learning Dual Pixel CMOS AF II focus system.
+ Shop now + `, + }, + }, + }), options: { + field: 'content', + entity: 'article', rules: [ { padding: '40px', diff --git a/libs/template/presets/storefront/experience/pages/index.ts b/libs/template/presets/storefront/experience/pages/index.ts index 31eecb200..ab973394b 100644 --- a/libs/template/presets/storefront/experience/pages/index.ts +++ b/libs/template/presets/storefront/experience/pages/index.ts @@ -10,4 +10,3 @@ export * from './order-confirmation-page'; export * from './product-page'; export * from './registration-page'; export * from './search-page'; -