Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
supproduction committed Aug 30, 2024
1 parent 7a8acc4 commit e5c030c
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 64 deletions.
3 changes: 3 additions & 0 deletions libs/domain/content/src/models/content.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
declare global {
interface ContentFields {
/**
* Page or component config. // ExperienceComponent
*/
component: undefined;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
)
),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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}`)
)
),
]);
}

Expand Down
1 change: 0 additions & 1 deletion libs/domain/content/src/resolvers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './cms-page-description-meta.resolver';
export * from './cms-page-title-meta.resolver';

7 changes: 5 additions & 2 deletions libs/domain/content/src/services/cms/cms-providers.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion libs/domain/content/src/services/cms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from './cms-providers';
export * from './contentful';
export * from './storyblok';
export * from './strapi';

Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions libs/platform/experience/data-text/data-text.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class DataTextComponent extends TextMixin(

protected $data = computed<string | undefined>(() => {
const { entity: type, field } = this.$options();
console.log(type, field);
return this.entityService
.getField<string>({ element: this, type, field })
.pipe(catchError(() => of()));
Expand Down
60 changes: 29 additions & 31 deletions libs/template/presets/storefront/experience/pages/cms-pages.ts
Original file line number Diff line number Diff line change
@@ -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' },
],
}));
64 changes: 43 additions & 21 deletions libs/template/presets/storefront/experience/pages/home-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: [
{
Expand All @@ -70,18 +84,26 @@ export const homePage: ExperienceComponent = {
},
},
{
type: 'oryx-content-text',
content: {
data: {
text: `
<span class="subtitle">CANON EOS R7 System camera</span>
<h1 style="margin:20px 0;">Discover everything</h1>
<div class="h3" style="margin-bottom:20px;">EOS R7 wows with its ability to track fast-moving subjects with its Deep-learning Dual Pixel CMOS AF II focus system.</div>
<oryx-button href="/category/12">Shop now</oryx-button>
`,
},
},
...(featureVersion >= '1.5'
? {
type: 'oryx-data-text',
}
: {
type: 'oryx-content-text',
content: {
data: {
text: `
<span class="subtitle">CANON EOS R7 System camera</span>
<h1 style="margin:20px 0;">Discover everything</h1>
<div class="h3" style="margin-bottom:20px;">EOS R7 wows with its ability to track fast-moving subjects with its Deep-learning Dual Pixel CMOS AF II focus system.</div>
<oryx-button href="/category/12">Shop now</oryx-button>
`,
},
},
}),
options: {
field: 'content',
entity: 'article',
rules: [
{
padding: '40px',
Expand Down
1 change: 0 additions & 1 deletion libs/template/presets/storefront/experience/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export * from './order-confirmation-page';
export * from './product-page';
export * from './registration-page';
export * from './search-page';

0 comments on commit e5c030c

Please sign in to comment.